Exemple #1
0
    protected string RenderFileInfo(IFileObject file)
    {
        var    content = file.GetContent();
        string size    = VfsHelper.FormatFileSize(content.Size);

        return(String.Format("<div class=\"fileinfo date\">{1:d}</div><div class=\"fileinfo size\">{0}</div>",
                             size, content.LastModifiedTime));
    }
        private FindData ToFindData(IFileObject file)
        {
            var findData = new FindData(Path.GetFileName(file.Name));
            var fileInfo = file.GetContent();

            if (file.Type == FileType.Folder)
            {
                findData.Attributes |= FileAttributes.Directory;
            }
            else
            {
                findData.FileSize = fileInfo.Size;
            }
            findData.LastWriteTime = fileInfo.LastModifiedTime;
            fileInfo.Close();
            return(findData);
        }
Exemple #3
0
    protected IFileObject GetThumbnail(IFileObject originalFile, IFileSystem filesystem, string width, string height)
    {
        var resizeWidth  = AssertHelper.IsFuzzyEmpty(width) ? 0 : Convert.ToInt32(width);
        var resizeHeight = AssertHelper.IsFuzzyEmpty(height) ? 0 : Convert.ToInt32(height);

        if (resizeWidth == 0 && resizeHeight == 0)
        {
            return(originalFile);
        }
        var thumbnailFileName = String.Format("{0}-thumbnail{1}x{2}{3}",
                                              Path.Combine(Path.GetDirectoryName(originalFile.Name), Path.GetFileNameWithoutExtension(originalFile.Name)),
                                              resizeWidth,
                                              resizeHeight,
                                              Path.GetExtension(originalFile.Name)
                                              );
        var thumbnailFile = filesystem.ResolveFile(thumbnailFileName);

        return(!thumbnailFile.Exists()
                                                ? ImageHelper.SaveAndResizeImage(originalFile.GetContent().InputStream, filesystem, thumbnailFile, resizeWidth, resizeHeight)
                                                : thumbnailFile);
    }
 private FindData ToFindData(IFileObject file)
 {
     var findData = new FindData(Path.GetFileName(file.Name));
     var fileInfo = file.GetContent();
     if (file.Type == FileType.Folder) findData.Attributes |= FileAttributes.Directory;
     else findData.FileSize = fileInfo.Size;
     findData.LastWriteTime = fileInfo.LastModifiedTime;
     fileInfo.Close();
     return findData;
 }