public static void DeleteAllFiles(SharedFileFolder folder, IFileSystem fileSystem, string fileVirtualBasePath, SharedFilesConfiguration config)
        {
            // method implemented by Jean-Michel 2008-07-31

            // TODO: implement check whether versioning is enabled before calling this method
            // if we are keeping versions we should not delete the files

            if (folder == null) { return; }
            if (fileSystem == null) { return; }
            if (string.IsNullOrEmpty(fileVirtualBasePath)) { return; }
            if (folder.FolderId == -1) { return; }

            ArrayList folders = new ArrayList();
            ArrayList files = new ArrayList();
            using (IDataReader reader = SharedFile.GetSharedFiles(folder.ModuleId, folder.FolderId))
            {
                while (reader.Read())
                {
                    files.Add(Convert.ToInt32(reader["ItemID"]));
                }
            }

            using (IDataReader reader = SharedFileFolder.GetSharedFolders(folder.ModuleId, folder.FolderId))
            {
                while (reader.Read())
                {
                    folders.Add(Convert.ToInt32(reader["FolderID"]));
                }
            }

            foreach (int id in files)
            {
                SharedFile sharedFile = new SharedFile(folder.ModuleId, id);
                sharedFile.Delete();

                if (!config.EnableVersioning)
                {
                    fileSystem.DeleteFile(VirtualPathUtility.Combine(fileVirtualBasePath, sharedFile.ServerFileName));

                }
            }

            foreach (int id in folders)
            {
                SharedFileFolder subFolder = new SharedFileFolder(folder.ModuleId, id);

                DeleteAllFiles(subFolder, fileSystem, fileVirtualBasePath, config);

                SharedFileFolder.DeleteSharedFileFolder(id);
            }
        }
示例#2
0
        private void btnUpdateFile_Click(object sender, EventArgs e)
        {
            SiteUser siteUser = SiteUtils.GetCurrentSiteUser();
            if (siteUser == null) return;

            SharedFile file = new SharedFile(this.moduleId, this.itemId);
            file.ContentChanged += new ContentChangedEventHandler(sharedFile_ContentChanged);

            if((file.ItemId > 0)&&(file.ModuleId == this.moduleId))
            {
                file.FriendlyName = this.txtFriendlyName.Text;
                file.Description = edDescription.Text;
                file.FolderId = int.Parse(this.ddFolders.SelectedValue);
                if (file.FolderId > -1)
                {
                    SharedFileFolder folder = new SharedFileFolder(this.moduleId,file.FolderId);
                    file.FolderGuid = folder.FolderGuid;
                }
                if (file.ModuleGuid == Guid.Empty)
                {
                    Module m = new Module(moduleId);
                    file.ModuleGuid = m.ModuleGuid;

                }

                file.UploadUserId = siteUser.UserId;
                // really last mod date
                file.UploadDate = DateTime.UtcNow;

                file.Save();

            }
            CurrentPage.UpdateLastModifiedTime();
            CacheHelper.ClearModuleCache(moduleId);
            SiteUtils.QueueIndexing();
            if (hdnReturnUrl.Value.Length > 0)
            {
                WebUtils.SetupRedirect(this, hdnReturnUrl.Value);
                return;
            }

            WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
        }
示例#3
0
        private void btnDeleteFolder_Click(object sender, EventArgs e)
        {
            SharedFileFolder folder = new SharedFileFolder(this.moduleId, this.itemId);
            if ((folder.FolderId > 0) && (folder.ModuleId == this.moduleId))
            {
                SharedFilesHelper.DeleteAllFiles(folder, fileSystem, virtualSourcePath, config);
                SharedFileFolder.DeleteSharedFileFolder(this.itemId);

                CacheHelper.ClearModuleCache(moduleId);
                if (hdnReturnUrl.Value.Length > 0)
                {
                    WebUtils.SetupRedirect(this, hdnReturnUrl.Value);
                    return;
                }
            }

            WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
        }
示例#4
0
        public void ProcessRequest(HttpContext context)
        {
            base.Initialize(context);

            if (!UserCanEditModule(ModuleId, SharedFile.FeatureGuid))
            {
                log.Info("User has no edit permission so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (CurrentSite == null)
            {
                log.Info("CurrentSite is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (CurrentUser == null)
            {
                log.Info("CurrentUser is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (FileSystem == null)
            {
                log.Info("FileSystem is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (Request.Files.Count == 0)
            {
                log.Info("Posted File Count is zero so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (Request.Files.Count > SharedFilesConfiguration.MaxFilesToUploadAtOnce)
            {
                log.Info("Posted File Count is greater than allowed amount so returning 404");
                Response.StatusCode = 404;
                return;
            }

            module = GetModule(ModuleId, SharedFile.FeatureGuid);

            if (module == null)
            {
                log.Info("Module is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            itemId = WebUtils.ParseInt32FromQueryString("ItemID", itemId);
            currentFolderId = WebUtils.ParseInt32FromQueryString("frmData", currentFolderId);

            virtualSourcePath = "~/Data/Sites/" + CurrentSite.SiteId.ToInvariantString() + "/SharedFiles/";
            virtualHistoryPath = "~/Data/Sites/" + CurrentSite.SiteId.ToInvariantString() + "/SharedFiles/History/";

            Hashtable moduleSettings = ModuleSettings.GetModuleSettings(ModuleId);
            config = new SharedFilesConfiguration(moduleSettings);

            context.Response.ContentType = "text/plain";//"application/json";
            var r = new System.Collections.Generic.List<UploadFilesResult>();
            JavaScriptSerializer js = new JavaScriptSerializer();

            if (!FileSystem.FolderExists(virtualSourcePath))
            {
                FileSystem.CreateFolder(virtualSourcePath);
            }

            for (int f = 0; f < Request.Files.Count; f++)
            {
                HttpPostedFile file = Request.Files[f];

                string fileName = Path.GetFileName(file.FileName);

                SharedFile sharedFile;
                if ((itemId > -1) && (Request.Files.Count == 1))
                {
                    // updating an existing file
                    sharedFile = new SharedFile(ModuleId, itemId);

                    if (config.EnableVersioning)
                    {
                        bool historyCreated = SharedFilesHelper.CreateHistory(sharedFile, FileSystem, virtualSourcePath, virtualHistoryPath);
                        if (historyCreated)
                        {
                            sharedFile.ServerFileName = System.Guid.NewGuid().ToString() + ".config";
                        }

                    }
                }
                else
                {   // new file
                    sharedFile = new SharedFile();
                }
                sharedFile.ModuleId = ModuleId;
                sharedFile.ModuleGuid = module.ModuleGuid;
                sharedFile.OriginalFileName = fileName;
                sharedFile.FriendlyName = fileName;
                sharedFile.SizeInKB = (file.ContentLength / 1024);
                sharedFile.FolderId = currentFolderId;
                if (currentFolderId > -1)
                {
                    SharedFileFolder folder = new SharedFileFolder(ModuleId, currentFolderId);
                    sharedFile.FolderGuid = folder.FolderGuid;
                }
                sharedFile.UploadUserId = CurrentUser.UserId;
                sharedFile.UserGuid = CurrentUser.UserGuid;
                sharedFile.UploadDate = DateTime.UtcNow;

                sharedFile.ContentChanged += new ContentChangedEventHandler(sharedFile_ContentChanged);

                //file.SaveAs(Server.MapPath("~/Files/" + fileName));
                if (sharedFile.Save())
                {
                    string destPath = VirtualPathUtility.Combine(virtualSourcePath, sharedFile.ServerFileName);

                    using (Stream s = file.InputStream)
                    {
                        FileSystem.SaveFile(destPath, s, IOHelper.GetMimeType(Path.GetExtension(sharedFile.FriendlyName).ToLower()), true);
                    }

                }

                r.Add(new UploadFilesResult()
                {
                    //Thumbnail_url = savedFileName,
                    Name = fileName,
                    Length = file.ContentLength,
                    Type = file.ContentType
                });

            }

            CurrentPage.UpdateLastModifiedTime();
            CacheHelper.ClearModuleCache(ModuleId);
            SiteUtils.QueueIndexing();

            var uploadedFiles = new
            {
                files = r.ToArray()
            };
            var jsonObj = js.Serialize(uploadedFiles);
            context.Response.Write(jsonObj.ToString());
        }
        protected void btnNewFolder_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtNewDirectory.Text.Length > 0)
                {
                    SharedFileFolder folder = new SharedFileFolder();
                    folder.ParentId = CurrentFolderId;
                    folder.ModuleId = ModuleId;
                    Module m = new Module(ModuleId);
                    folder.ModuleGuid = m.ModuleGuid;
                    folder.FolderName = Path.GetFileName(txtNewDirectory.Text);
                    if (folder.Save())
                    {
                        BindData();
                    }
                }
            }
            catch(Exception ex)
            {
                lblError.Text = ex.Message;
            }

            upFiles.Update();
        }
 private void MoveUp()
 {
     if(CurrentFolderId > 0)
     {
         SharedFileFolder folder = new SharedFileFolder(ModuleId, CurrentFolderId);
         CurrentFolderId = folder.ParentId;
         BindData();
     }
     else
     {
         lblError.Text = SharedFileResources.RootDirectoryReached;
     }
 }
        private void DeleteItem(GridViewRow e)
        {
            string keys = dgFile.DataKeys[e.RowIndex].Value.ToString();
            char[] separator = {'~'};
            string[] args = keys.Split(separator);
            string type = args[1];

            if(type == "folder")
            {
                int folderID = int.Parse(args[0]);
                SharedFileFolder folder = new SharedFileFolder(this.ModuleId, folderID);
                //folder.DeleteAllFiles(this.filePath);
                SharedFilesHelper.DeleteAllFiles(folder, fileSystem, fileVirtualBasePath, config);
                SharedFileFolder.DeleteSharedFileFolder(folderID);

                //TODO: file content changed event so re-index

            }

            if(type == "file")
            {
                int fileID = int.Parse(args[0]);
                SharedFile sharedFile = new SharedFile(this.ModuleId, fileID);
                if (!config.EnableVersioning)
                {
                    fileSystem.DeleteFile(VirtualPathUtility.Combine(fileVirtualBasePath, sharedFile.ServerFileName));
                }
                sharedFile.Delete();

                sharedFile.ContentChanged += new ContentChangedEventHandler(sharedFile_ContentChanged);

            }
        }
 public static List<int> GetAllParentsFolderIds(SharedFileFolder folder, List<SharedFileFolder> allFolders)
 {
     return GetAllParentsFolder(folder, allFolders).Select(fld => fld.FolderId).ToList();
 }
        protected void dgFile_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            SiteUser siteUser = SiteUtils.GetCurrentSiteUser();
            if (siteUser == null) return;

            try
            {
                GridView grid = (GridView)sender;
                TextBox txtEditName = (TextBox)grid.Rows[e.RowIndex].Cells[1].FindControl("txtEditName");
                if (txtEditName.Text.Trim().Length < 1)
                    return;

                string keys = grid.DataKeys[e.RowIndex].Value.ToString();
                char[] separator = { '~' };
                string[] args = keys.Split(separator);
                string type = args[1];

                if (type == "folder")
                {
                    int folderID = int.Parse(args[0]);
                    SharedFileFolder folder = new SharedFileFolder(this.ModuleId, folderID);
                    folder.FolderName = Path.GetFileName(txtEditName.Text);
                    folder.Save();

                }

                if (type == "file")
                {
                    int fileID = int.Parse(args[0]);
                    SharedFile sharedFile = new SharedFile(this.ModuleId, fileID);
                    sharedFile.ContentChanged += new ContentChangedEventHandler(sharedFile_ContentChanged);
                    sharedFile.FriendlyName = Path.GetFileName(txtEditName.Text);
                    sharedFile.UploadUserId = siteUser.UserId;
                    sharedFile.UploadDate = DateTime.UtcNow; //lastModDate
                    sharedFile.Save();

                }

                dgFile.EditIndex = -1;
                BindData();

            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
            }
            upFiles.Update();
        }
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            // as long as javascript is available this code should never execute
            // because the standard file input ir replaced by javascript and the file upload happens
            // at the service url /SharedFiles/upload.ashx
            // this is fallback implementation

            if (!fileSystem.FolderExists(fileVirtualBasePath))
            {
                fileSystem.CreateFolder(fileVirtualBasePath);
            }

            SiteUser siteUser = SiteUtils.GetCurrentSiteUser();

            if (siteUser == null) { WebUtils.SetupRedirect(this, Request.RawUrl); return; }

            if (uploader.HasFile)
            {
                SharedFile sharedFile = new SharedFile();

                string fileName = Path.GetFileName(uploader.FileName);

                sharedFile.ModuleId = ModuleId;
                sharedFile.ModuleGuid = ModuleConfiguration.ModuleGuid;
                sharedFile.OriginalFileName = fileName;
                sharedFile.FriendlyName = fileName;
                //sharedFile.SizeInKB = (int)(file.ContentLength / 1024);
                sharedFile.SizeInKB = (int)(uploader.FileContent.Length / 1024);
                sharedFile.FolderId = CurrentFolderId;
                if (CurrentFolderId > -1)
                {
                    SharedFileFolder folder = new SharedFileFolder(ModuleId, CurrentFolderId);
                    sharedFile.FolderGuid = folder.FolderGuid;
                }
                sharedFile.UploadUserId = siteUser.UserId;
                sharedFile.UserGuid = siteUser.UserGuid;

                sharedFile.ContentChanged += new ContentChangedEventHandler(sharedFile_ContentChanged);

                if (sharedFile.Save())
                {
                    string destPath = VirtualPathUtility.Combine(fileVirtualBasePath, sharedFile.ServerFileName);

                    using (Stream s = uploader.FileContent)
                    {
                        fileSystem.SaveFile(destPath, s, IOHelper.GetMimeType(Path.GetExtension(sharedFile.FriendlyName).ToLower()), true);
                    }

                }
            }

            WebUtils.SetupRedirect(this, Request.RawUrl);
        }
        public void InstallContent(Module module, string configInfo)
        {
            if (string.IsNullOrEmpty(configInfo)) { return; }

            SiteSettings siteSettings = new SiteSettings(module.SiteId);
            SiteUser admin = SiteUser.GetNewestUser(siteSettings);

            string upLoadPath = HostingEnvironment.MapPath("~/Data/Sites/" + module.SiteId.ToInvariantString() + "/SharedFiles/");
            if (!Directory.Exists(upLoadPath))
            {
                Directory.CreateDirectory(upLoadPath);
            }

             XmlDocument xml = new XmlDocument();

            using (StreamReader stream = File.OpenText(HostingEnvironment.MapPath(configInfo)))
            {
                xml.LoadXml(stream.ReadToEnd());
            }

            XmlAttributeCollection attributes = xml.DocumentElement.Attributes;

            if (attributes["filePath"].Value.Length > 0)
            {
                string destPath = "~/Data/Sites/" + module.SiteId.ToInvariantString() + "/SharedFiles/";

                if (!Directory.Exists(HostingEnvironment.MapPath(destPath)))
                {
                    Directory.CreateDirectory(HostingEnvironment.MapPath(destPath));
                }

                IOHelper.CopyFolderContents(HostingEnvironment.MapPath(attributes["filePath"].Value), HostingEnvironment.MapPath(destPath));

                destPath = "~/Data/Sites/" + module.SiteId.ToInvariantString() + "/SharedFiles/History/";

                if (!Directory.Exists(HostingEnvironment.MapPath(destPath)))
                {
                    Directory.CreateDirectory(HostingEnvironment.MapPath(destPath));
                }

            }

            foreach (XmlNode node in xml.DocumentElement.ChildNodes)
            {
                if (node.Name == "file") //root level files
                {
                    CreateFile(module, null, admin, node);
                }
            }

            XmlNode foldersNode = null;

            foreach (XmlNode node in xml.DocumentElement.ChildNodes)
            {
                if (node.Name == "folders")
                {
                    foldersNode = node;
                    break;
                }
            }

            if (foldersNode != null)
            {
                foreach (XmlNode folderNode in foldersNode.ChildNodes)
                {
                    if (folderNode.Name == "folder")
                    {
                        XmlAttributeCollection folderAttributes = folderNode.Attributes;

                        if ((folderAttributes["folderName"] != null)&&(folderAttributes["folderName"].Value.Length > 0))
                        {
                            //create folder
                            SharedFileFolder folder = new SharedFileFolder();
                            folder.ModuleId = module.ModuleId;
                            folder.ModuleGuid = module.ModuleGuid;
                            folder.FolderName = folderAttributes["folderName"].Value;
                            folder.Save();

                            foreach (XmlNode fileNode in folderNode.ChildNodes)
                            {
                                if (fileNode.Name == "file")
                                {
                                    CreateFile(module, folder, admin, fileNode);
                                }
                            }

                        }

                    }
                }

            }
        }
        private void CreateFile(Module module, SharedFileFolder folder, SiteUser siteUser, XmlNode fileNode)
        {
            SharedFile sharedFile = new SharedFile();

            sharedFile.ModuleId = module.ModuleId;
            sharedFile.ModuleGuid = module.ModuleGuid;
            if (folder != null)
            {
                sharedFile.FolderId = folder.FolderId;
                sharedFile.FolderGuid = folder.FolderGuid;
            }

            if (siteUser != null)
            {
                sharedFile.UploadUserId = siteUser.UserId;
                sharedFile.UserGuid = siteUser.UserGuid;
            }

            XmlAttributeCollection fileAttributes = fileNode.Attributes;

            if (fileAttributes["originalFileName"] != null)
            {
                sharedFile.OriginalFileName = fileAttributes["originalFileName"].Value;
            }

            if (fileAttributes["friendlyName"] != null)
            {
                sharedFile.FriendlyName = fileAttributes["friendlyName"].Value;
            }

            if (fileAttributes["serverFileName"] != null)
            {
                sharedFile.ServerFileName = fileAttributes["serverFileName"].Value;
            }

            if (fileAttributes["sortOrder"] != null)
            {
                int size = 0;
                if (int.TryParse(fileAttributes["sortOrder"].Value, out size))
                {
                    sharedFile.SizeInKB = size;
                }
            }

            sharedFile.Save();
        }
示例#13
0
        private static List<SharedFileFolder> LoadListFromReader(IDataReader reader)
        {
            List<SharedFileFolder> sharedFileFolderList = new List<SharedFileFolder>();
            try
            {
                while (reader.Read())
                {
                    SharedFileFolder sharedFileFolder = new SharedFileFolder();
                    sharedFileFolder.folderID = Convert.ToInt32(reader["FolderID"]);
                    sharedFileFolder.moduleID = Convert.ToInt32(reader["ModuleID"]);
                    sharedFileFolder.folderName = reader["FolderName"].ToString();
                    sharedFileFolder.parentID = Convert.ToInt32(reader["ParentID"]);
                    sharedFileFolder.moduleGuid = new Guid(reader["ModuleGuid"].ToString());
                    sharedFileFolder.folderGuid = new Guid(reader["FolderGuid"].ToString());
                    if (reader["ParentGuid"] != DBNull.Value)
                    {
                        sharedFileFolder.parentGuid = new Guid(reader["ParentGuid"].ToString());
                    }

                    sharedFileFolderList.Add(sharedFileFolder);

                }
            }
            finally
            {
                reader.Close();
            }

            return sharedFileFolderList;
        }
示例#14
0
        private void btnUpdateFolder_Click(object sender, EventArgs e)
        {
            SharedFileFolder folder = new SharedFileFolder(this.moduleId, this.itemId);
            if((folder.FolderId > 0)&&(folder.ModuleId == this.moduleId))
            {
                folder.FolderName = this.txtFolderName.Text;
                folder.ParentId = int.Parse(this.ddFolderList.SelectedValue);
                folder.Save();

            }

            CacheHelper.ClearModuleCache(moduleId);
            if (hdnReturnUrl.Value.Length > 0)
            {
                WebUtils.SetupRedirect(this, hdnReturnUrl.Value);
                return;
            }

            WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
        }
        private void BindData()
        {
            if(CurrentFolderId > -1)
            {
                SharedFileFolder folder = new SharedFileFolder(this.ModuleId, CurrentFolderId);

                btnGoUp.Visible = true;
                rptFoldersLinks.Visible = true;

                if (displaySettings.ShowClickableFolderPathCrumbs)
                {
                    lblCurrentDirectory.Visible = false;

                    // by Thomas N
                    List<SharedFileFolder> allFolders = SharedFileFolder.GetSharedModuleFolderList(folder.ModuleId);
                    rptFoldersLinks.DataSource = SharedFilesHelper.GetAllParentsFolder(folder, allFolders);
                    IEnumerable<SharedFileFolder> fullPathList = SharedFilesHelper.GetAllParentsFolder(folder, allFolders).Concat(Enumerable.Repeat(folder, 1));
                    rptFoldersLinks.DataSource = fullPathList;
                    rptFoldersLinks.DataBind();
                }
                else
                {
                    lblCurrentDirectory.Text = folder.FolderName;
                }

            }
            else
            {
                lblCurrentDirectory.Visible = false;
                btnGoUp.Visible = false;
                rptFoldersLinks.Visible = false;
            }

            DataView dv = new DataView(SharedFileFolder.GetFoldersAndFiles(ModuleId, CurrentFolderId));

            dv.Sort = "type ASC, filename" + " " + config.DefaultSort;
            dgFile.DataSource = dv;
            dgFile.DataBind();
            lblCounter.Text = dgFile.Rows.Count.ToString() + " "
                + SharedFileResources.FileManagerObjectsLabel;
        }
示例#16
0
        private void PopulateFolderControls()
        {
            Title = SiteUtils.FormatPageTitle(siteSettings, SharedFileResources.SharedFilesEditFolderLabel);
            heading.Text = SharedFileResources.SharedFilesEditFolderLabel;
            SharedFileFolder folder = new SharedFileFolder(this.moduleId, this.itemId);
            if((folder.FolderId > 0)&&(folder.ModuleId == this.moduleId))
            {
                this.pnlNotFound.Visible = false;
                this.pnlFile.Visible = false;
                this.pnlFolder.Visible = true;

                this.txtFolderName.Text = folder.FolderName;

                List<SharedFileFolder> allFolders = SharedFileFolder.GetSharedModuleFolderList(folder.ModuleId);

                this.ddFolderList.DataSource = allFolders;
                this.ddFolderList.DataBind();

                this.ddFolderList.Items.Insert(0,new ListItem("Root","-1"));
                this.ddFolderList.SelectedValue = folder.ParentId.ToString();

                // prevent a folder from being its own parent
                ListItem item = this.ddFolderList.Items.FindByText(folder.FolderName);
                if(item != null)
                this.ddFolderList.Items.Remove(item);

                //// prevent a children folder from being parent
                //// build list
                List<int> toRemove = new List<int>();
                foreach (ListItem fldItem in this.ddFolderList.Items)
                {
                    //SharedFileFolder currentFolder = new SharedFileFolder(this.moduleId, Convert.ToInt32(fldItem.Value));
                    SharedFileFolder currentFolder = SharedFilesHelper.GetFolderFromListById(Convert.ToInt32(fldItem.Value), allFolders);
                    if (currentFolder != null)
                    {
                        if (SharedFilesHelper.GetAllParentsFolderIds(currentFolder, allFolders).Contains(folder.FolderId))
                        {
                            toRemove.Add(currentFolder.FolderId);
                        }
                    }
                }
                // remove list
                foreach (int itemToRemove in toRemove)
                {
                    this.ddFolderList.Items.Remove(this.ddFolderList.Items.FindByValue(itemToRemove.ToInvariantString()));
                }
            }
            else
            {
                this.pnlNotFound.Visible = true;
                this.pnlFolder.Visible = false;
                this.pnlFile.Visible = false;
            }
        }
示例#17
0
 public static List<SharedFileFolder> GetAllParentsFolder(SharedFileFolder folder, List<SharedFileFolder> allFolders)
 {
     List<SharedFileFolder> list = new List<SharedFileFolder>();
     while (folder.ParentId > -1)
     {
         folder = GetFolderFromListById(folder.ParentId, allFolders);
         list.Insert(0, folder);// note: Insert at 0 to preserve a path stucture
     }
     return list;
 }