From 943b4dcb5fa597264f13f2d0cfa305f4dd542dbe Mon Sep 17 00:00:00 2001 From: Alex-TIMEHACK Date: Fri, 18 Aug 2017 20:41:45 +0100 Subject: Wordpad Save, Open and Save As --- TimeHACK.Engine/FileDialogBoxManager.cs | 35 ++++++++++++--------------------- 1 file changed, 13 insertions(+), 22 deletions(-) (limited to 'TimeHACK.Engine') diff --git a/TimeHACK.Engine/FileDialogBoxManager.cs b/TimeHACK.Engine/FileDialogBoxManager.cs index 7ed4725..59533fa 100644 --- a/TimeHACK.Engine/FileDialogBoxManager.cs +++ b/TimeHACK.Engine/FileDialogBoxManager.cs @@ -38,27 +38,18 @@ namespace TimeHACK.Engine } } - //public static void SaveTextFile(string path, string contents, int fileIcon) - //{ - // try - // { - // File.WriteAllText(path, contents); - // FileSystemFolderInfo theDir = Newtonsoft.Json.JsonConvert.DeserializeObject(File.ReadAllText(Path.Combine(Path.GetPathRoot(path), "_data.info"))); - - - - // using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read)) - // { - // theDir.Files.Add(new THFileInfo() - // { - // Name = Path.GetFileName(path), - // ByteSize = (int)fs.Length, - // FileIcon = fileIcon - // }); - // } - - - // } catch { } - //} + public static void SaveRtfDocument(RichTextBox tbox, string path) + { + int fileBytes = 0; + tbox.SaveFile(path); + fileBytes = File.ReadAllText(path).Length; + + THFileInfo info = new THFileInfo(); + info.Name = Path.GetFileName(path); + info.FileIcon = 17; + info.ByteSize = fileBytes; + SaveSystem.CurrentSave.BytesLeft -= fileBytes; + SaveSystem.UpdateDirectoryInfo(new FileInfo(path).Directory.FullName, info); + } } } -- cgit v1.2.3