public bool Delete(DeleteOprationInfo deleteInfo) { var rootPath = HostingEnvironment.ApplicationHost.GetPhysicalPath(); var tempPath = _fileSystemManager.RelativeToAbsolutePath(Config.ThumbnailPath); if (tempPath == null) { throw new KhodkarInvalidException(LanguageManager.ToAsErrorMessage(ExceptionKey.PathNotFound, Config.ThumbnailPath)); } var thumbnailRootPath = tempPath.ToLower(); var path = _fileSystemManager.RelativeToAbsolutePath(AuthorizeManager.AuthorizeActionOnPath(deleteInfo.Path, ActionKey.DeleteFromDisk)); if (path == null) { throw new KhodkarInvalidException(LanguageManager.ToAsErrorMessage(ExceptionKey.PathNotFound, deleteInfo.Path)); } Parallel.ForEach(deleteInfo.Files, file => { var realPath = path + "/" + file; _fileSystemManager.DeleteFile(realPath); var thumbnailPath = realPath.Substring(rootPath.Length); if (_fileSystemManager.FileExist(thumbnailRootPath + thumbnailPath)) { _fileSystemManager.DeleteFile(thumbnailRootPath + thumbnailPath); } }); Parallel.ForEach(deleteInfo.Folders, folder => { var realPath = path + "/" + folder; _fileSystemManager.DeleteDirectory(realPath); var thumbnailPath = realPath.Substring(rootPath.Length); if (_fileSystemManager.DirectoryExists(thumbnailRootPath + thumbnailPath)) { _fileSystemManager.DeleteDirectory(thumbnailRootPath + thumbnailPath); } }); return(true); }
public bool Delete(DeleteOprationInfo deleteInfo) { return(_fileSystemBiz.Delete(deleteInfo)); }