public static string DeleteFile(string strSourceFile, PortalSettings settings, bool ClearCache)
 {
     string retValue = "";
     int PortalId = GetFolderPortalId(settings);
     string folderName = Globals.GetSubFolderPath(strSourceFile, PortalId);
     string fileName = GetFileName(strSourceFile);
     CommonLibrary.Services.FileSystem.FolderController objFolders = new CommonLibrary.Services.FileSystem.FolderController();
     CommonLibrary.Services.FileSystem.FolderInfo objFolder = objFolders.GetFolder(PortalId, folderName, false);
     if (FolderPermissionController.CanAdminFolder(objFolder))
     {
         try
         {
             DeleteFile(strSourceFile);
             DeleteFile(strSourceFile + Globals.glbProtectedExtension);
             CommonLibrary.Services.FileSystem.FileController objFileController = new CommonLibrary.Services.FileSystem.FileController();
             objFileController.DeleteFile(PortalId, fileName, objFolder.FolderID, ClearCache);
         }
         catch (IOException ioEx)
         {
             retValue += "<br>" + string.Format(Localization.GetString("FileInUse"), strSourceFile);
             ioEx.ToString();
         }
         catch (Exception ex)
         {
             retValue = ex.Message;
         }
     }
     else
     {
         retValue += "<br>" + string.Format(Localization.GetString("InsufficientFolderPermission"), folderName);
     }
     return retValue;
 }
 private static void RemoveOrphanedFile(CommonLibrary.Services.FileSystem.FileInfo objFile, int PortalId)
 {
     CommonLibrary.Services.FileSystem.FileController objFileController = new CommonLibrary.Services.FileSystem.FileController();
     string strFile = "";
     switch (objFile.StorageLocation)
     {
         case (int)CommonLibrary.Services.FileSystem.FolderController.StorageLocationTypes.InsecureFileSystem:
             strFile = objFile.PhysicalPath;
             break;
         case (int)CommonLibrary.Services.FileSystem.FolderController.StorageLocationTypes.SecureFileSystem:
             strFile = objFile.PhysicalPath + Globals.glbProtectedExtension;
             break;
     }
     if (!String.IsNullOrEmpty(strFile))
     {
         if (!File.Exists(strFile))
         {
             objFileController.DeleteFile(PortalId, objFile.FileName, objFile.FolderId, true);
         }
     }
 }