From 9ffdd871b6e7698517a869dbf49491dd9af6b50d Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Sat, 8 Sep 2018 14:53:05 +0300 Subject: [PATCH] savesPath --- OWTrack/Form1.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/OWTrack/Form1.cs b/OWTrack/Form1.cs index ccf8ea5..391e4ed 100644 --- a/OWTrack/Form1.cs +++ b/OWTrack/Form1.cs @@ -12,6 +12,7 @@ namespace OWTrack Tracker tr = new Tracker(); private const string IS_RUNNING = "Running"; private const string NOT_RUNNING = " Not running"; + private string savesPath = Directory.GetCurrentDirectory() + "/saves/data.json"; private bool SRonce = false; public Form1() @@ -21,8 +22,7 @@ namespace OWTrack checkStatus(); update(); label4.Text = Program.Version.ToString(); - Text = "OWTrack " + Program.Version.ToString(); - + Text = "OWTrack " + Program.Version.ToString(); } private void checkStatus() @@ -46,6 +46,7 @@ namespace OWTrack private void loadSave() { + Directory.CreateDirectory("saves"); if (saveExist()) { tr.wins = savedTracker().wins; @@ -61,9 +62,9 @@ namespace OWTrack { try { - if (File.Exists(Directory.GetCurrentDirectory() + "/data.json")) + if (File.Exists(savesPath)) { - using (StreamReader st = new StreamReader(Directory.GetCurrentDirectory() + "/data.json")) + using (StreamReader st = new StreamReader(savesPath)) { string line = st.ReadLine(); if (line.Contains("Overwatch.exe")) @@ -124,7 +125,7 @@ namespace OWTrack { try { - return JsonConvert.DeserializeObject(File.ReadAllText(Directory.GetCurrentDirectory() + "/data.json")); + return JsonConvert.DeserializeObject(File.ReadAllText(savesPath)); } catch (Exception e) { @@ -173,7 +174,7 @@ namespace OWTrack } else srLabel.Text = tr.startSR.ToString() + " - " + tr.srDiff(); srTextBox.Text = null; - File.WriteAllText(Directory.GetCurrentDirectory() + "/data.json", JsonConvert.SerializeObject(tr)); + File.WriteAllText(Directory.GetCurrentDirectory() + "/saves/data.json", JsonConvert.SerializeObject(tr)); } private void clearBut_Click(object sender, EventArgs e)