public static FileBrowserTreeDataResponse LoadFileBrowserTreeData(string path) { string parameters = ""; string tempPath = HttpContext.Current.Server.MapPath("~/_layouts/15/GroupDocs_Annotation_SharePoint_WebPart/App_Data/"); if (!string.IsNullOrEmpty(parameters)) { tempPath = Path.Combine(tempPath, parameters); } FileTreeContainer tree = null; try { tree = annotator.LoadFileTree(new FileTreeOptions(tempPath)); } catch (Exception ex) { throw; } List <FileDescription> treeNodes = tree.FileTree; FileBrowserTreeDataResponse data = new FileBrowserTreeDataResponse { nodes = ToFileTreeNodes(parameters, treeNodes).ToArray(), count = tree.FileTree.Count }; return(data); }
public HttpResponseMessage loadFileTree(AnnotationPostedDataEntity fileTreeRequest) { string relDirPath = fileTreeRequest.path; // get file list from storage path FileTreeOptions fileListOptions = new FileTreeOptions(relDirPath); // get temp directory name string tempDirectoryName = new AnnotationConfig().TempFolderName; try { FileTreeContainer fileListContainer = AnnotationImageHandler.LoadFileTree(fileListOptions); List <FileDescriptionEntity> fileList = new List <FileDescriptionEntity>(); // parse files/folders list foreach (FileDescription fd in fileListContainer.FileTree) { FileDescriptionEntity fileDescription = new FileDescriptionEntity(); fileDescription.guid = fd.Guid; // check if current file/folder is temp directory or is hidden FileInfo fileInfo = new FileInfo(fileDescription.guid); if (tempDirectoryName.ToLower().Equals(fileDescription.guid) || fileInfo.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 (System.Exception ex) { // set exception message return(Request.CreateResponse(HttpStatusCode.OK, new Resources().GenerateException(ex))); } }
public static FileBrowserTreeDataResponse LoadFileBrowserTreeData(string path) { string parameters = ""; string tempPath = AppDomain.CurrentDomain.GetData("DataDirectory") + "/"; if (!string.IsNullOrEmpty(parameters)) { tempPath = Path.Combine(tempPath, parameters); } FileTreeContainer tree = annotator.LoadFileTree(new FileTreeOptions(tempPath)); List <FileDescription> treeNodes = tree.FileTree; FileBrowserTreeDataResponse data = new FileBrowserTreeDataResponse { nodes = ToFileTreeNodes(parameters, treeNodes).ToArray(), count = tree.FileTree.Count }; return(data); }
public ActionResult LoadFileBrowserTreeData(LoadFileBrowserTreeDataParameters parameters) { string path = AppDomain.CurrentDomain.GetData("DataDirectory") + "/"; if (!string.IsNullOrEmpty(parameters.Path)) { path = Path.Combine(path, parameters.Path); } FileTreeContainer tree = annotator.LoadFileTree(new FileTreeOptions(path)); List <FileDescription> treeNodes = tree.FileTree; FileBrowserTreeDataResponse data = new FileBrowserTreeDataResponse { nodes = ToFileTreeNodes(parameters.Path, treeNodes).ToArray(), count = tree.FileTree.Count }; JavaScriptSerializer serializer = new JavaScriptSerializer(); string serializedData = serializer.Serialize(data); return(Content(serializedData, "application/json")); }
/// <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 FileTreeOptions(Path); // Load file tree list for ViewerConfig.StoragePath FileTreeContainer container = imageHandler.LoadFileTree(options); foreach (var node in container.FileTree) { 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:LoadFileTree }