public override void save(ExportedLevel level) { FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.Read); BinaryWriter bw = new BinaryWriter(fs); level.Write(bw); bw.Close(); }
private void levelSaver_DoWork(object sender, DoWorkEventArgs e) { try { Console.Out.WriteLine("Backing up level " + LevelFilename); ExportedLevel exlvl = levelEditorControl1.Level.getExport(); string backupPath = System.IO.Path.Combine(Application.StartupPath, "Backup"); if (!System.IO.Directory.Exists(backupPath)) { System.IO.Directory.CreateDirectory(backupPath); } string filename; if (levelEditorControl1.Level.isExported) { filename = System.IO.Path.GetFileName(LevelFilename); } else { filename = LevelFilename + ".nml"; } System.IO.FileStream fs = new System.IO.FileStream(System.IO.Path.Combine(backupPath, filename), System.IO.FileMode.Create); System.IO.BinaryWriter bw = new System.IO.BinaryWriter(fs); exlvl.Write(bw); bw.Close(); } catch (Exception ex) { } }
public override void save(ExportedLevel level) { ByteArrayInputStream strm = new ByteArrayInputStream(new byte[0]); System.IO.BinaryWriter bw = new System.IO.BinaryWriter(strm); level.Write(bw); copyData(strm.getData()); }
public void Save() { ExportedLevel exlvl = getExport(); if (isClipboard) { ByteArrayInputStream strm = new ByteArrayInputStream(new byte[0]); System.IO.BinaryWriter bw = new System.IO.BinaryWriter(strm); exlvl.Write(bw); Clipboard.SetText("NSMBeLevel|" + Convert.ToBase64String(ROM.LZ77_Compress(strm.getData())) + "|"); } else if (isExported) { System.IO.FileStream fs = new System.IO.FileStream(ExportedFileName, System.IO.FileMode.Create); System.IO.BinaryWriter bw = new System.IO.BinaryWriter(fs); exlvl.Write(bw); } else { LevelFile.replace(exlvl.LevelFile, this); BGFile.replace(exlvl.BGFile, this); } }