Beispiel #1
0
        private static string GetStorageFilename()
        {
            var projectRoot       = GamePathUtilities.GetProjectRoot();
            var savedGameLocation = projectRoot + @"\App_Data";
            var filename          = savedGameLocation + @"\heroes.json";

            return(filename);
        }
Beispiel #2
0
        public void LogToDisk(string message, LogLevel level = LogLevel.Debug)
        {
            var path = GamePathUtilities.GetDebugFilePath();

            // This text is added only once to the file.
            if (!File.Exists(path))
            {
                // Create a file to write to.
                using (var sw = File.CreateText(path))
                {
                    sw.WriteLine("{0} - {1}", DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss.fff"), "starting log file");
                }
            }

            if ((int)level >= (int)minLevel)
            {
                // Create a file to write to.
                using (var sw = File.AppendText(path))
                {
                    sw.WriteLine("{0} - {1}", DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss.fff"), message);
                }
            }
        }