Пример #1
0
 public void fileProcesses()
 {
     f.createDirectory(fileDirectory);
     fileDirectory += @"\preferences.txt";
     f.createFile(fileDirectory);
     f.ReadData(fileDirectory);
 }
Пример #2
0
        private void storeProfiles()
        {
            FileHandlingUtilites f = new FileHandlingUtilites();

            userCount = 0;
            string fileDirectory = Environment.CurrentDirectory + @"\Data\Profiles\" + currentAccount + @"\";

            f.createDirectory(fileDirectory);

            string accountsDirectory = fileDirectory + currentAccount + "Profiles.txt";

            f.createFile(accountsDirectory);
            FileStream   accountsFile  = new FileStream(accountsDirectory, FileMode.Open, FileAccess.Read);
            StreamReader accountStream = new StreamReader(accountsFile);

            string passwordDirectory = fileDirectory + currentAccount + "Passwords.txt";

            f.createFile(passwordDirectory);
            FileStream   passwordFile   = new FileStream(passwordDirectory, FileMode.Open, FileAccess.Read);
            StreamReader passwordStream = new StreamReader(passwordFile);

            accountStream.BaseStream.Seek(0, SeekOrigin.Begin);
            passwordStream.BaseStream.Seek(0, SeekOrigin.Begin);
            string passwordStr = "", accountStr = "";

            while ((accountStr != null || passwordStr != null))
            {
                accountStr  = accountStream.ReadLine();
                passwordStr = passwordStream.ReadLine();
                if (userCount == size || accountStr == "" || passwordStr == "")
                {
                    accountStream.Close();
                    passwordStream.Close();
                    accountsFile.Close();
                    passwordFile.Close();
                    break;
                }
                if (accountStr != null && passwordStr != null)
                {
                    if (accountStr != "\n" || accountStr != "" || passwordStr != "\n" || passwordStr != "")
                    {
                        string imageLocation = Environment.CurrentDirectory + @"\Data\Profiles\Profiles Icons\" + (userCount).ToString() + ".png";
                        Console.WriteLine(userCount + "\n");
                        profiles[userCount]  = accountStr;
                        passwords[userCount] = passwordStr;
                        switch (userCount)
                        {
                        case 0:
                            ID1.ImageLocation = imageLocation;
                            ID1.SizeMode      = PictureBoxSizeMode.Zoom;
                            label1.Text       = accountStr;
                            break;

                        case 1:
                            ID2.ImageLocation = imageLocation;
                            ID2.SizeMode      = PictureBoxSizeMode.Zoom;
                            label2.Text       = accountStr;
                            break;

                        case 2:
                            ID3.ImageLocation = imageLocation;
                            ID3.SizeMode      = PictureBoxSizeMode.Zoom;
                            label3.Text       = accountStr;
                            break;

                        case 3:
                            ID4.ImageLocation = imageLocation;
                            ID4.SizeMode      = PictureBoxSizeMode.Zoom;
                            label4.Text       = accountStr;
                            break;

                        case 4:
                            ID5.ImageLocation = imageLocation;
                            ID5.SizeMode      = PictureBoxSizeMode.Zoom;
                            label5.Text       = accountStr;
                            break;
                        }
                        userCount++;
                    }
                }
            }
            accountStream.Close();
            passwordStream.Close();
            accountsFile.Close();
            passwordFile.Close();
        }