private string GetServerPath(TargetDirectoryEnum eTargetDir) { string dirUrl = string.Empty; string dirPath = string.Empty; switch (eTargetDir) { case TargetDirectoryEnum.DIRECTORY_PROCESSED: { dirUrl = @"..\..\" + ConfigurationManager.AppSettings["UploadFolderInitialProcessed"]; dirPath = Server.MapPath(dirUrl); } break; case TargetDirectoryEnum.DIRECTORY_CANCELLED: { dirUrl = @"..\..\" + ConfigurationManager.AppSettings["UploadFolderInitialCancelled"]; dirPath = Server.MapPath(dirUrl); } break; default: { throw new IndException("Unknown TargetDirectoryEnum member: " + eTargetDir.ToString()); } } return(dirPath); }
private void MoveFileToDirectory(TargetDirectoryEnum eTargetDir, string fileName) { string dirPath; try { dirPath = GetServerPath(eTargetDir); if (Directory.Exists(dirPath)) { File.Copy(fileName, dirPath + @"\" + Path.GetFileName(fileName), true); File.Delete(fileName); } else { throw new IndException(ApplicationMessages.IMPORT_DESTINATION_UNKNOWN); } } catch (Exception ex) { throw new IndException(string.Format(ApplicationMessages.IMPORT_FILE_ERROR_ON_MOVING, Path.GetFileName(fileName), ex.Message)); } }