Program to populate a text file in C#
I am trying to use make a function using random to generate random strings and add them to the file. But it keeps repeating the same string over and over.
Need ideas on how to do that.
string va = "2346789ABCDEFGHJKLMNPQRTUVWXYZabcdefghjkmnpqrtuvwxyz";
Random ran = new Random();
string[] txt = new string[] {};
for (int i = 0; i < 25; i++)
{
while (txt.Length < 8)
{
txt[i]= va[0 .. ran.Next()];
}
}
for (int i = 0; i < txt.Length; i++) {
File.AppendAllText($"Externalfiles/{Exfile}", txt[I]);
I am looking for a function that uses only string and random. And gives multiple random strings.
my program has the need for an iterative loop which in itself gives a new string for every iteration so that I can add those strings directly to the file.
Other Methods are also appreciated. :))