Example #1
0
        /// <summary>
        /// Loading the date and time from the text file in the application data directory.
        /// </summary>
        private void LoadLastUpdateCheckFromFile()
        {
            DataFunctions.LoadStringFromFile(this.UpdateFilePath);
            string loadedString = DataFunctions.LoadedString;

            if (string.IsNullOrEmpty(loadedString))
            {
                loadedString = DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss", CultureInfo.InvariantCulture);
            }

            DateTime outputDateTime;
            bool     result = DateTime.TryParse(loadedString, out outputDateTime);

            if (!result)
            {
                return;
            }

            TimeSpan timeDifference = DateTime.Now - outputDateTime;

            if (timeDifference.Hours >= 24)
            {
                this.InformAboutNewVersion();
            }

            DataFunctions.SaveTextDataToFile(this.UpdateFilePath, loadedString, false);
        }
        /// <summary>
        /// Adds a string message to the log.
        /// </summary>
        /// <param name="stringData">The string data that will be added to the log.</param>
        private void AddToLog(string stringData)
        {
            try
            {
                FileInfo fileInfo = new FileInfo(this.logPath);
                long     fileSize = fileInfo.Length;

                if (fileSize >= this.logMaxSize)
                {
                    if (DataFunctions.LoadStringFromFile(this.logPath) > 0)
                    {
                        string loadedString = DataFunctions.LoadedString;
                        int    halfSize     = loadedString.Length / 2;
                        loadedString = StringFunctions.SubstringString(loadedString, halfSize, loadedString.Length - halfSize);

                        DataFunctions.SaveTextDataToFile(this.logPath, loadedString, true);
                    }
                }
            }
            catch (UnauthorizedAccessException unathException)
            {
                LogSystem.Instance.AddToLog(unathException, false);
            }

            string outputString = StringFunctions.GetCurrentTimeString + " - " + stringData + "\r\n";

            DataFunctions.SaveTextDataToFile(this.logPath, outputString, true);
        }
        /// <summary>
        /// Initializes the <see cref="Settings"/> properties.
        /// </summary>
        private void InitSettings()
        {
            this.ProgramAppDataDirectory = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                Resources.Program_Name);
            this.CheckForAppDir();

            this.WindowNamesTxtFilePath = @"tvpb Window Names.txt";
            this.WindowNamesTxtFilePath = Path.Combine(this.ProgramAppDataDirectory, this.WindowNamesTxtFilePath);

            if (!File.Exists(this.WindowNamesTxtFilePath))
            {
                DataFunctions.AddCollectionToFile(this.WindowNamesTxtFilePath, this.WindowNames);
            }
        }
Example #4
0
 /// <summary>
 /// Saving the last update check date and time to the application data file.
 /// </summary>
 private void SaveLastUpdateCheckToFile()
 {
     this.LastUpdateCheck = DateTime.Now;
     DataFunctions.SaveTextDataToFile(this.UpdateFilePath, this.LastUpdateCheck.ToString(DateTimeFormat, CultureInfo.InvariantCulture), false);
 }
 /// <summary>
 /// Loading the window names from text file to <see cref="WindowNames"/>.
 /// </summary>
 public void Load()
 {
     this.windowNames = DataFunctions.ReadTextFromFile(this.WindowNamesTxtFilePath);
 }
 /// <summary>
 /// Saving the window names from <see cref="WindowNames"/> to text file.
 /// </summary>
 public void Save()
 {
     DataFunctions.WriteCollectionToFile(this.WindowNamesTxtFilePath, this.WindowNames);
 }