public static void ReadUnformattedDataFromFile(string filePath)
        {
            try
            {
                if (!File.Exists(filePath))
                {
                    return;
                }

                using (var sr = new StreamReader(filePath))
                {
                    string line;

                    while ((line = sr.ReadLine()) != null)
                    {
                        UnformattedDataCollection.AddItem(line);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
        public static void ReadUnformattedDataFromFile(string filePath)
        {
            try
            {
                if (!File.Exists(filePath))
                {
                    return;
                }

                using (var sr = new StreamReader(filePath))
                {
                    string line;

                    while ((line = sr.ReadLine()) != null)
                    {
                        UnformattedDataCollection.AddItem(line);
                    }
                }
            }
            catch (ArgumentNullException ex)
            {
                MyMessagesClass.ErrorMessage = "The file path value is a null string. " + filePath;

                Debug.WriteLine(ex.ToString());

                MyMessagesClass.ShowErrorMessageBox();
            }
            catch (ArgumentException ex)
            {
                MyMessagesClass.ErrorMessage = "The file path value is an empty string.";

                Debug.WriteLine(ex.ToString());
                MyMessagesClass.ShowErrorMessageBox();
            }
            catch (FileNotFoundException ex)
            {
                MyMessagesClass.ErrorMessage = "Unable to locate this file. " + filePath;

                Debug.WriteLine(ex.ToString());

                MyMessagesClass.ShowErrorMessageBox();
            }
            catch (DirectoryNotFoundException ex)
            {
                MyMessagesClass.ErrorMessage = "Unable to locate the directory.";

                Debug.WriteLine(ex.ToString());
                Debug.WriteLine(ex.ToString());
                MyMessagesClass.ShowErrorMessageBox();
            }
            catch (IOException ex)
            {
                MyMessagesClass.ErrorMessage = "File path has invalid characters in it.";

                Debug.WriteLine(ex.ToString());

                MyMessagesClass.ShowErrorMessageBox();
            }
        }
        public static void ReadUnformattedDataFromFile(string filePath)
        {
            try
            {
                if (!File.Exists(filePath))
                {
                    return;
                }

                using (var sr = new StreamReader(filePath))
                {
                    string line;

                    while ((line = sr.ReadLine()) != null)
                    {
                        UnformattedDataCollection.AddItem(line);
                    }
                }
            }
            catch (ArgumentNullException ex)
            {
                MyMessagesClass.ErrorMessage = V11 + filePath;

                Debug.WriteLine(ex.ToString());

                MyMessagesClass.ShowErrorMessageBox();
            }
            catch (ArgumentException ex)
            {
                MyMessagesClass.ErrorMessage = V12;

                Debug.WriteLine(ex.ToString());
                MyMessagesClass.ShowErrorMessageBox();
            }
            catch (FileNotFoundException ex)
            {
                MyMessagesClass.ErrorMessage = V13 + filePath;

                Debug.WriteLine(ex.ToString());

                MyMessagesClass.ShowErrorMessageBox();
            }
            catch (DirectoryNotFoundException ex)
            {
                MyMessagesClass.ErrorMessage = V14;

                Debug.WriteLine(ex.ToString());
                Debug.WriteLine(ex.ToString());
                MyMessagesClass.ShowErrorMessageBox();
            }
            catch (IOException ex)
            {
                MyMessagesClass.ErrorMessage = V15;

                Debug.WriteLine(ex.ToString());

                MyMessagesClass.ShowErrorMessageBox();
            }
        }
Esempio n. 4
0
        public static void ReadUnformattedDataFromFile(string filePath)
        {
            if (!File.Exists(filePath))
            {
                return;
            }

            using (var sr = new StreamReader(filePath))
            {
                string line;

                while ((line = sr.ReadLine()) != null)
                {
                    UnformattedDataCollection.AddItem(line);
                }
            }
        }