public void ExportToFile(Guid dataIdentifier, string outputFile, ExportFileBehaviour exportFileBehaviour) { switch (exportFileBehaviour) { case ExportFileBehaviour.OverrideWhenAlreadyExists: if (File.Exists(outputFile)) { File.Delete(outputFile); } break; case ExportFileBehaviour.SkipWhenAlreadyExists: if (File.Exists(outputFile)) { return; } break; case ExportFileBehaviour.ThrowExceptionWhenAlreadyExists: if (File.Exists(outputFile)) { throw new Exception(String.Format("File {0} already exists", outputFile)); } break; default: throw new NotSupportedException(string.Format("Unsupported export behavious ({0})", exportFileBehaviour)); } byte[] fileData = GetFileByteData(dataIdentifier, StreamStateBehaviour.OpenNewStreamForReading, StreamStateBehaviour.OpenNewStreamForReading); File.WriteAllBytes(outputFile, fileData); }
public static void ExportToFile(string fileStorageName, Guid dataIdentifier, string outputFile, ExportFileBehaviour exportFileBehaviour) { var fileStorageHandler = FileStorageHandler.Open(fileStorageName); fileStorageHandler.ExportToFile(dataIdentifier, outputFile, exportFileBehaviour); }
public static void ExportToFile(string fileStorageName, Guid dataIdentifier, string outputFile, ExportFileBehaviour exportFileBehaviour) { FileStorageHandler fileStorageHandler = FileStorageHandler.Open(fileStorageName); fileStorageHandler.ExportToFile(dataIdentifier, outputFile, exportFileBehaviour); }