public HttpResponseMessage loadFileTree(PostedDataWrapper postedData)
        {
            String relDirPath = "";

            // get posted data
            if (postedData != null)
            {
                relDirPath = postedData.path;
            }
            // get file list from storage path
            FileListOptions fileListOptions = new FileListOptions(relDirPath);
            // get temp directory name
            String tempDirectoryName = new ViewerConfig().CacheFolderName;

            try
            {
                FileListContainer fileListContainer = viewerHtmlHandler.GetFileList(fileListOptions);

                List <FileDescriptionWrapper> fileList = new List <FileDescriptionWrapper>();
                // parse files/folders list
                foreach (FileDescription fd in fileListContainer.Files)
                {
                    FileDescriptionWrapper fileDescription = new FileDescriptionWrapper();
                    fileDescription.guid = fd.Guid;
                    // check if current file/folder is temp directory or is hidden
                    if (tempDirectoryName.Equals(fd.Name) || new FileInfo(fileDescription.guid).Attributes.HasFlag(FileAttributes.Hidden))
                    {
                        // ignore current file and skip to next one
                        continue;
                    }
                    else
                    {
                        // set file/folder name
                        fileDescription.name = fd.Name;
                    }
                    // set file type
                    fileDescription.docType = fd.DocumentType;
                    // set is directory true/false
                    fileDescription.isDirectory = fd.IsDirectory;
                    // set file size
                    fileDescription.size = fd.Size;
                    // add object to array list
                    fileList.Add(fileDescription);
                }
                return(Request.CreateResponse(HttpStatusCode.OK, fileList));
            }
            catch (Exception ex)
            {
                // set exception message
                ErrorMsgWrapper errorMsgWrapper = new ErrorMsgWrapper();
                errorMsgWrapper.message   = ex.Message;
                errorMsgWrapper.exception = ex;
                return(Request.CreateResponse(HttpStatusCode.OK, errorMsgWrapper));
            }
        }
Exemple #2
0
        /// <summary>
        /// Load directory structure as file tree
        /// </summary>
        /// <param name="Path"></param>
        public static void LoadFileTree(String Path)
        {
            //ExStart:LoadFileTree
            // Create/initialize image handler
            ViewerImageHandler imageHandler = new ViewerImageHandler(Utilities.GetConfigurations());

            // Load file tree list for custom path
            var options = new FileListOptions(Path);

            // Load file tree list for ViewerConfig.StoragePath
            FileListContainer container = imageHandler.GetFileList(options);

            foreach (var node in container.Files)
            {
                if (node.IsDirectory)
                {
                    Console.WriteLine("Guid: {0} | Name: {1} | LastModificationDate: {2}",
                                      node.Guid,
                                      node.Name,
                                      node.LastModificationDate);
                }
                else
                {
                    Console.WriteLine("Guid: {0} | Name: {1} | Document type: {2} | File type: {3} | Extension: {4} | Size: {5} | LastModificationDate: {6}",
                                      node.Guid,
                                      node.Name,
                                      node.DocumentType,
                                      node.FileType,
                                      node.Extension,
                                      node.Size,
                                      node.LastModificationDate);
                }
            }

            //ExEnd:LoadFioleTree
        }