private void CreateMeg(object sender, RoutedEventArgs e) { var meg = new MegaFile(); if (!AddFiles(meg)) { MessageBox.Show("Error Adding Files"); return; } try { using (var stream = File.Open(FilePath.Text, FileMode.Create, FileAccess.Write, FileShare.None)) { meg.Close(stream, MegaFile.Format.V1, new MegaFile.EncryptionKey?()); } } catch (Exception) { MessageBox.Show("Error writing .meg file"); } }
private static void Save(MegaFile meg, string outputPath) { Directory.CreateDirectory(Path.GetDirectoryName(outputPath) !); using var stream = File.Open(outputPath, FileMode.Create, FileAccess.Write, FileShare.None); meg.Close(stream, MegaFile.Format.V1, new MegaFile.EncryptionKey?()); }