Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- namespace TxtFileSizeGenerator
- {
- class Program
- {
- static void Main(string[] args)
- {
- while (true)
- {
- Console.WriteLine("Byte, Kb or Mb");
- string ans = Console.ReadLine();
- File.Delete("txt.txt");
- switch (ans.ToLower())
- {
- case "byte":
- Console.WriteLine("Successfully Saved");
- Console.WriteLine("");
- randomString(1, "byte");
- break;
- case "kb":
- Console.WriteLine("Successfully Saved");
- Console.WriteLine("");
- randomString(1, "kb");
- break;
- case "mb":
- Console.WriteLine("");
- randomString(1024, "mb");
- break;
- }
- }
- }
- static void randomString(int size, string type)
- {
- Console.WriteLine("How Many?");
- int amount;
- if (!int.TryParse(Console.ReadLine(), out amount))
- {
- Console.WriteLine("Error, this is a text only field");
- }
- else
- {
- char[] letters = "qwertyuiopasdfghjklzxcvbnm1234567890".ToCharArray();
- Random r = new Random();
- string random = string.Empty;
- for (int i = 0; i < 1 * size; i++)
- {
- random += letters[r.Next(0, 35)].ToString();
- }
- if (type != "byte")
- {
- for (int i = 0; i < 1024 * amount; i++)
- {
- File.AppendAllText("txt.txt", random);
- }
- Console.WriteLine("Successfully Saved");
- System.Threading.Thread.Sleep(2000);
- Console.Clear();
- }
- else
- {
- for (int i = 0; i < amount; i++)
- {
- File.AppendAllText("txt.txt", random);
- }
- Console.WriteLine("Successfully Saved");
- System.Threading.Thread.Sleep(2000);
- Console.Clear();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement