public static ArrayList GetFilesByFolder( int PortalId, int folderId ) { FileController objFileController = new FileController(); return CBO.FillCollection( objFileController.GetFiles( PortalId, folderId ), typeof( Services.FileSystem.FileInfo ) ); }
public static ArrayList GetFileList(int PortalId, string strExtensions, bool NoneSpecified, string Folder, bool includeHidden) { ArrayList arrFileList = new ArrayList(); if (NoneSpecified) { arrFileList.Add(new FileItem("", "<" + Localization.GetString("None_Specified") + ">")); } string portalRoot = null; if (PortalId == Null.NullInteger) { portalRoot = HostMapPath; } else { PortalController objPortals = new PortalController(); PortalInfo objPortal = objPortals.GetPortal(PortalId); portalRoot = objPortal.HomeDirectoryMapPath; } FolderInfo objFolder = FileSystemUtils.GetFolder(PortalId, Folder); if (objFolder != null) { FileController objFiles = new FileController(); IDataReader dr = objFiles.GetFiles(PortalId, objFolder.FolderID); while (dr.Read()) { if ((strExtensions.ToUpper().IndexOf(dr["Extension"].ToString().ToUpper(), 0) + 1) != 0||strExtensions == "") { string filePath = (portalRoot + dr["Folder"].ToString() + dr["fileName"].ToString()).Replace("/", "\\"); int StorageLocation = 0; if (dr["StorageLocation"] != null) { StorageLocation = System.Convert.ToInt32(dr["StorageLocation"]); switch (StorageLocation) { case 1: // Secure File System filePath = filePath + glbProtectedExtension; break; case 2: // Secure Database break; default: // Insecure File System break; } } // check if file exists - as the database may not be synchronized with the file system // Make sure its not a file stored in the db, if it is we don't worry about seeing if it exists if (!(StorageLocation == 2)) { if (File.Exists(filePath)) { // check if file is hidden if (includeHidden) { arrFileList.Add(new FileItem(dr["FileID"].ToString(), dr["FileName"].ToString())); } else { System.IO.FileAttributes attributes = File.GetAttributes(filePath); if (!((attributes & FileAttributes.Hidden) == FileAttributes.Hidden)) { arrFileList.Add(new FileItem(dr["FileID"].ToString(), dr["FileName"].ToString())); } } } } else { // File is stored in DB - Just add to arraylist arrFileList.Add(new FileItem(dr["FileID"].ToString(), dr["FileName"].ToString())); } //END Change } } dr.Close(); } return arrFileList; }