Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void Button1_Click(object sender, EventArgs e)
- {
- location = textBox1.Text;
- amount = Int32.Parse(textBox2.Text);
- progressBar1.Maximum = amount;
- progressBar1.Step = 1;
- for(int i = 0; i < amount; i++)
- {
- progressBar1.PerformStep();
- string path = location + "/" + RandomString(7) + ".txt";
- if (!File.Exists(path))
- {
- using (StreamWriter sw = File.CreateText(path))
- {
- sw.WriteLine("Hello");
- sw.WriteLine("And");
- sw.WriteLine("Welcome");
- }
- }
- }
- }
- public static string RandomString(int length)
- {
- const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
- return new string(Enumerable.Repeat(chars, length)
- .Select(s => s[random.Next(s.Length)]).ToArray());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement