private static void RemoveOrphanedFile( Services.FileSystem.FileInfo objFile, int PortalId ) { FileController objFileController = new FileController(); string strFile = ""; if( objFile.StorageLocation == (int)FolderController.StorageLocationTypes.InsecureFileSystem ) { strFile = objFile.PhysicalPath; } else if( objFile.StorageLocation == (int)FolderController.StorageLocationTypes.SecureFileSystem ) { strFile = objFile.PhysicalPath + Globals.glbProtectedExtension; } if( !String.IsNullOrEmpty( strFile ) ) { if( !( File.Exists( strFile ) ) ) { objFileController.DeleteFile( PortalId, objFile.FileName, objFile.FolderId, true ); } } }
/// <summary> /// Deletes a file /// </summary> /// <param name="strSourceFile">The File to delete</param> /// <param name="settings">The Portal Settings for the Portal/Host Account</param> /// <param name="ClearCache"></param> public static string DeleteFile( string strSourceFile, PortalSettings settings, bool ClearCache ) { string retValue = ""; try { //try and delete the Insecure file AttemptFileDeletion( strSourceFile ); //try and delete the Secure file AttemptFileDeletion( strSourceFile + Globals.glbProtectedExtension ); string folderName = Globals.GetSubFolderPath( strSourceFile ); string fileName = GetFileName( strSourceFile ); int PortalId = GetFolderPortalId( settings ); //Remove file from DataBase FileController objFileController = new FileController(); FolderController objFolders = new FolderController(); FolderInfo objFolder = objFolders.GetFolder( PortalId, folderName ); objFileController.DeleteFile( PortalId, fileName, objFolder.FolderID, ClearCache ); } catch( Exception ex ) { retValue = ex.Message; } return retValue; }