private StorageReturnValue UploadFileProcess(string uploadToLocation, List <FileStorageAttachment> uploadedFile) { result = new StorageReturnValue(false, FileStorageProperties.GetInstance.WrongInitialManagement, null); if (!string.IsNullOrEmpty(uploadToLocation) & uploadedFile != null) { uploadToLocation = uploadToLocation.Trim(); if (FileStorageProperties.GetInstance.FileStorageType == StorageType.Azure) { result = FileValidation.GetInstance.CheckFolderStorageExistAndCreate(uploadToLocation); if (!result.IsSuccess) { return(result); } result = FileValidation.GetInstance.IsFileExtAllowed(uploadedFile); if (!result.IsSuccess) { return(result); } List <FileStorageAttachment> uploadedFileSuccess = new List <FileStorageAttachment>(); foreach (FileStorageAttachment item in uploadedFile) { string fileName = item.GetFileName; string fileToUpload = Path.Combine(uploadToLocation, fileName); result = fileManagement.CreateFileUpload(item.FileAttachment, fileToUpload); if (result.IsSuccess) { uploadedFileSuccess.Add(item); } else { break; } } if (!result.IsSuccess) { /*if any error when uploaded,all data will be deleted also*/ foreach (FileStorageAttachment item in uploadedFile) { string fileName = item.GetFileName; string fileToUpload = Path.Combine(uploadToLocation, fileName); result = fileManagement.DeleteFile(fileToUpload); } } } } return(result); }
public StorageReturnValue DeleteFile(string pathFileNameWithExt) { return(fileManagement.DeleteFile(pathFileNameWithExt)); }