Exemplo n.º 1
0
        public static void SaveWaterToFileMethod(string WaterAmount, int difference)
        {
            string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)) + "/water";

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            string WaterFileName = "w" + CombineDifferenceFileName.CombineDifferenceFileNameMethod(difference);

            using (var writer = new StreamWriter(File.Create(path + "/" + WaterFileName)))
            {
                writer.Write(WaterAmount);
            }
        }
Exemplo n.º 2
0
        public static void CollectionToFileMethod(List <ObservableCollection <MealToDisplay> > collection, int difference)
        {
            string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "saves");

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            string todayFileName = CombineDifferenceFileName.CombineDifferenceFileNameMethod(difference);

            using (var writer = new StreamWriter(File.Create(path + "/" + todayFileName)))
            {
                string ContentToSave = MealsListToString.MealsListToStringMethod(collection);

                writer.Write(ContentToSave);
            }
        }
Exemplo n.º 3
0
        public static string ReadFileToWaterMethod(int difference)
        {
            string dayNameToReadFrom = "w" + CombineDifferenceFileName.CombineDifferenceFileNameMethod(difference);

            string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)) + "/water/" + dayNameToReadFrom;

            string result = "";

            try
            {
                using (var reader = new StreamReader(path))
                {
                    result = reader.ReadToEnd();
                }
            }
            catch
            {
                result = "0";
            }

            return(result);
        }