Advertisement
Guest User

test

a guest
Sep 16th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. private void Button1_Click(object sender, EventArgs e)
  2. {
  3. location = textBox1.Text;
  4. amount = Int32.Parse(textBox2.Text);
  5. progressBar1.Maximum = amount;
  6. progressBar1.Step = 1;
  7. for(int i = 0; i < amount; i++)
  8. {
  9. progressBar1.PerformStep();
  10. string path = location + "/" + RandomString(7) + ".txt";
  11. if (!File.Exists(path))
  12. {
  13. using (StreamWriter sw = File.CreateText(path))
  14. {
  15. sw.WriteLine("Hello");
  16. sw.WriteLine("And");
  17. sw.WriteLine("Welcome");
  18. }
  19. }
  20.  
  21. }
  22. }
  23.  
  24. public static string RandomString(int length)
  25. {
  26. const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  27. return new string(Enumerable.Repeat(chars, length)
  28. .Select(s => s[random.Next(s.Length)]).ToArray());
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement