/// <summary>
        /// If adding new user  then write there name to the Art2MSpell user names file.
        /// </summary>
        /// <returns></returns>
        /// <created>art2m,5/17/2019</created>
        /// <changed>art2m,5/17/2019</changed>
        public static bool WriteUserNameFile()
        {
            MyMessages.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            var dirPath = DirectoryFileOperations.CheckDirectoryPathExistsCreate();

            var filePath = DirectoryFileOperations.CreatePathToUserFile(dirPath);


            /*if (!string.IsNullOrEmpty(op.CheckDirectoryPathExistsCreate()))
             * {
             *
             * };
             *
             *
             * if (!File.Exists(filePath))
             * {
             *  File.Create(filePath).Dispose();
             *
             *  using (TextWriter tw = new StreamWriter(filePath))
             *  {
             *      tw.WriteLine(SpellingPropertiesClass.UserName);
             *  }
             * }
             * else if (File.Exists(filePath))
             * {
             *  using (TextWriter tw = new StreamWriter(filePath))
             *  {
             *      tw.WriteLine(SpellingPropertiesClass.UserName);
             *  }
             * }*/

            return(true);
        }
        /// <summary>
        /// If adding new user  then write there name to the Art2MSpell user names file.
        /// </summary>
        /// <returns>True if write successful else false.</returns>
        /// <created>art2m,5/17/2019</created>
        /// <changed>art2m,5/17/2019</changed>
        public static bool WriteUserNameFile()
        {
            MyMessages.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            try
            {
                var dirPath = DirectoryFileOperations.CheckDirectoryPathExistsCreate();

                var filePath = DirectoryFileOperations.CreatePathToUserFile(dirPath);

                // Append line to the file.
                using (var writer = new StreamWriter(filePath, true))
                {
                    writer.WriteLine(SpellingPropertiesClass.UserName);
                }

                return true;
            }
            catch (UnauthorizedAccessException ex)
            {
                Console.WriteLine(ex);
                throw;
            }
            catch (ArgumentNullException ex)
            {

            }
            catch (ArgumentNullException ex)
        }
        /// <summary>
        /// Read user name file into collection.
        /// so user can log in with there name. This
        /// is used to keep each users spelling list together so they can choose
        /// an all ready saved spelling list to practice.
        /// </summary>
        /// <returns></returns>
        /// <created>art2m,5/20/2019</created>
        /// <changed>art2m,5/20/2019</changed>
        public static bool ReadUserNameFile()
        {
            // TODO: Add error handling to this method.

            MyMessages.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            var dirPath  = DirectoryFileOperations.CheckDirectoryPathExistsCreate();
            var filePath = DirectoryFileOperations.CreatePathToUserFile(dirPath);

            try
            {
                using (var reader = new StreamReader(filePath))
                {
                    string user;
                    while ((user = reader.ReadLine()) != null)
                    {
                        unc.AddItem(user.Trim());
                    }
                }

                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// If adding new user  then write there name to the Art2MSpell user names file.
        /// </summary>
        /// <returns>True if write successful else false.</returns>
        /// <created>art2m,5/17/2019</created>
        /// <changed>art2m,5/17/2019</changed>
        public static bool WriteUserNameFile()
        {
            MyMessages.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            try
            {
                var dirPath = DirectoryFileOperations.CheckDirectoryPathExistsCreate();

                var filePath = DirectoryFileOperations.CreatePathToUserFile(dirPath);

                // Append line to the file.
                using (var writer = new StreamWriter(filePath, true))
                {
                    writer.WriteLine(SpellingPropertiesClass.UserName);
                }

                return(true);
            }
            catch (UnauthorizedAccessException ex)
            {
                MyMessages.ErrorMessage = "You do not have access writes for this operation.";

                Debug.WriteLine(ex.ToString());

                MyMessages.ShowErrorMessageBox();

                return(false);
            }
            catch (ArgumentNullException ex)
            {
                MyMessages.ErrorMessage = "The path variable contains a null string."
            }
            catch (ArgumentException ex)
            {
                MyMessages.ErrorMessage = "The file path value is a null string. "
            }
            catch (DirectoryNotFoundException ex)
            {
                MyMessages.ErrorMessage = "Unable to locate the directory."

                                          Debug.WriteLine(ex.ToString());

                MyMessages.ShowErrorMessageBox();
            }
            catch (PathTooLongException ex)
            {
            }
            catch (SecurityException ex)
            {
            }
            catch (IOException ex)
            {
            }
        }
        public static bool ReadUserNameFile(string filePath)
        {
            MyMessages.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            var dirPath  = DirectoryFileOperations.CheckDirectoryPathExistsCreate();
            var filePath = DirectoryFileOperations.CreatePathToUserFile(dirPath);

            using var reader = new StreamReader(filePath)
                  {
                  }

                  return(true);
        }
Esempio n. 6
0
        /// <summary>
        /// If adding new user  then write there name to the Art2MSpell user names file.
        /// </summary>
        /// <returns>True if write successful else false.</returns>
        /// <created>art2m,5/17/2019</created>
        /// <changed>art2m,5/17/2019</changed>
        public static bool WriteUserNameFile()
        {
            MyMessages.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            var dirPath = DirectoryFileOperations.CheckDirectoryPathExistsCreate();

            var filePath = DirectoryFileOperations.CreatePathToUserFile(dirPath);

            // Append line to the file.
            using (var writer = new StreamWriter(filePath, true))
            {
                writer.WriteLine(SpellingPropertiesClass.UserName);
            }

            return(true);
        }
Esempio n. 7
0
        public static bool ReadUserNameFile(string filePath)
        {
            MyMessages.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            var dirPath  = DirectoryFileOperations.CheckDirectoryPathExistsCreate();
            var filePath = DirectoryFileOperations.CreatePathToUserFile(dirPath);

            var userColl = new UserCollection();

            using (var reader = new StreamReader(filePath))
            {
                string user;
                while ((user = reader.ReadLine()) != null)
                {
                }
            }

            return(true);
        }
Esempio n. 8
0
        /// <summary>
        /// If adding new user  then write there name to the Art2MSpell user names file.
        /// </summary>
        /// <returns>True if write successful else false.</returns>
        /// <created>art2m,5/17/2019</created>
        /// <changed>art2m,5/17/2019</changed>
        public static bool WriteUserNameFile()
        {
            MyMessages.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            try
            {
                var dirPath = DirectoryFileOperations.CheckDirectoryPathExistsCreate();

                var filePath = DirectoryFileOperations.CreatePathToUserFile(dirPath);

                // Append line to the file.
                using (var writer = new StreamWriter(filePath, true))
                {
                    writer.WriteLine(SpellingPropertiesClass.UserName);
                }

                return(true);
            }
            catch (UnauthorizedAccessException ex)
            {
                MyMessages.ErrorMessage = "You do not have "
            }
            catch (ArgumentNullException ex)
            {
            }
            catch (ArgumentException ex)
            {
            }
            catch (DirectoryNotFoundException ex)
            {
            }
            catch (PathTooLongException ex)
            {
            }
            catch (SecurityException ex)
            {
            }
            catch (IOException ex)
            {
            }
        }
        /// <summary>
        /// Read user name file into collection.
        /// so user can log in with there name. This
        /// is used to keep each users spelling list together so they can choose
        /// an all ready saved spelling list to practice.
        /// </summary>
        /// <returns></returns>
        /// <created>art2m,5/20/2019</created>
        /// <changed>art2m,5/20/2019</changed>
        public static bool ReadUserNameFile()
        {
            // TODO: Add error handling to this method.

            MyMessages.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            var dirPath  = DirectoryFileOperations.CheckDirectoryPathExistsCreate();
            var filePath = DirectoryFileOperations.CreatePathToUserFile(dirPath);

            var userColl = new UsersNameCollection();

            using (var reader = new StreamReader(filePath))
            {
                string user;
                while ((user = reader.ReadLine()) != null)
                {
                    userColl.AddItem(user.Trim());
                }
            }

            return(true);
        }
Esempio n. 10
0
        /// <summary>
        ///     Read user name file into collection.
        ///     so user can log in with there name. This
        ///     is used to keep each users spelling list together so they can choose
        ///     an all ready saved spelling list to practice.
        /// </summary>
        /// <returns></returns>
        /// <created>art2m,5/20/2019</created>
        /// <changed>art2m,5/20/2019</changed>
        public static bool ReadUserNameFile()
        {
            MyMessages.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            var dirPath  = DirectoryFileOperations.CheckDirectoryPathExistsCreate();
            var filePath = DirectoryFileOperations.CreatePathToUserFile(dirPath);

            try
            {
                using (var reader = new StreamReader(filePath))
                {
                    string user;
                    while ((user = reader.ReadLine()) != null)
                    {
                        Unc.AddItem(user.Trim());
                    }
                }

                return(true);
            }
            catch (ArgumentNullException ex)
            {
                MyMessages.ErrorMessage = "The file path value is a null string. " + filePath;

                Debug.WriteLine(ex.ToString());

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

                Debug.WriteLine(ex.ToString());
                MyMessages.ShowErrorMessageBox();

                return(false);
            }
            catch (FileNotFoundException ex)
            {
                MyMessages.ErrorMessage = "Unable to locate this file. " + filePath;

                Debug.WriteLine(ex.ToString());

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

                Debug.WriteLine(ex.ToString());
                MyMessages.ShowErrorMessageBox();

                return(false);
            }
            catch (IOException ex)
            {
                MyMessages.ErrorMessage = "File path has invalid characters in it.";

                Debug.WriteLine(ex.ToString());

                MyMessages.ShowErrorMessageBox();

                return(false);
            }
        }