public static ArrayList GetFilesByFolder(int PortalId, int folderId)
 {
     CommonLibrary.Services.FileSystem.FileController objFileController = new CommonLibrary.Services.FileSystem.FileController();
     return CBO.FillCollection(objFileController.GetFiles(PortalId, folderId), typeof(CommonLibrary.Services.FileSystem.FileInfo));
 }
Пример #2
0
 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;
     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 = null;
         try
         {
             dr = objFiles.GetFiles(PortalId, objFolder.FolderID);
             while (dr.Read())
             {
                 if (FilenameMatchesExtensions(dr["FileName"].ToString(), strExtensions))
                 {
                     string filePath = (portalRoot + dr["Folder"].ToString() + dr["fileName"].ToString()).Replace("/", "\\");
                     int StorageLocation = 0;
                     if (dr["StorageLocation"] != null)
                     {
                         StorageLocation = Convert.ToInt32(dr["StorageLocation"]);
                         switch (StorageLocation)
                         {
                             case 1:
                                 filePath = filePath + glbProtectedExtension;
                                 break;
                             case 2:
                                 break;
                             default:
                                 break;
                         }
                     }
                     if (StorageLocation != 2)
                     {
                         if (File.Exists(filePath))
                         {
                             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
                     {
                         arrFileList.Add(new FileItem(dr["FileID"].ToString(), dr["FileName"].ToString()));
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             Exceptions.LogException(ex);
         }
         finally
         {
             CBO.CloseDataReader(dr, true);
         }
     }
     return arrFileList;
 }