private void saveToFileName() { try { using (var mem = new MemoryStream()) { using (var writer = new BinaryWriter(mem)) { File.Write(writer); mem.Seek(0, SeekOrigin.Begin); using (var fs = new FileStream(FileName, FileMode.Create, FileAccess.Write)) { mem.WriteTo(fs); OnFileSaved?.Invoke(this, new FileSavedEventArgs { FileName = FileName, Stream = fs, File = File }); fs.Close(); } } } } catch (Exception e) { MainController.Get().QueueLog("Failed to save the file(s)! They are probably in use.\n" + e.ToString()); } }
private void ProcessCommand(uint commandCode) { switch (commandCode) { case (uint)NppMsg.NPPN_READY: OnReady?.Invoke(); break; case (uint)NppMsg.NPPN_TBMODIFICATION: _funcItems.RefreshItems(); SetToolBarIcons(); break; case (uint)SciMsg.SCN_CHARADDED: break; case (uint)NppMsg.NPPN_SHUTDOWN: OnShutDown?.Invoke(); _funcItems.Dispose(); break; case (uint)NppMsg.NPPN_FILESAVED: OnFileSaved?.Invoke(); break; case (uint)NppMsg.NPPN_BUFFERACTIVATED: OnFileChanged?.Invoke(); break; } }