Meistro
Meistro
CC#
Created by Meistro on 4/24/2023 in #help
❔ Random take a File from a Folder
but well ! thank you very much guys !
19 replies
CC#
Created by Meistro on 4/24/2023 in #help
❔ Random take a File from a Folder
would usedRandomNumbers.clear(); also work every time I call it ?
19 replies
CC#
Created by Meistro on 4/24/2023 in #help
❔ Random take a File from a Folder
might this one be correct ?
static public List<int> usedRandomNumbers = new List<int>();
static Random random = new Random(DateTime.Now.Millisecond);

public string GetRandomFileFromGivenFolderPath()
{
if (FolderPath_RandomFiles.Text != " ")
{
// Get an array of all file paths in the specified folder
string[] files = Directory.GetFiles(FolderPath_RandomFiles.Text);

// If no files are found, return null
if (files.Length == 0)
{
UpdateRichTextBox("No Files found!");
return "null";
}

// Generate a random number between 0 and the number of files minus 1
int randomIndex = -1;
do
{
randomIndex = random.Next(0, files.Length);
} while (usedRandomNumbers.Contains(randomIndex));

usedRandomNumbers.Add(randomIndex);

// Return the file path at the random index
return files[randomIndex];
}
else
{
UpdateRichTextBox("Folder path for \"random Files Path\" not found!");
return "null";
}
}
static public List<int> usedRandomNumbers = new List<int>();
static Random random = new Random(DateTime.Now.Millisecond);

public string GetRandomFileFromGivenFolderPath()
{
if (FolderPath_RandomFiles.Text != " ")
{
// Get an array of all file paths in the specified folder
string[] files = Directory.GetFiles(FolderPath_RandomFiles.Text);

// If no files are found, return null
if (files.Length == 0)
{
UpdateRichTextBox("No Files found!");
return "null";
}

// Generate a random number between 0 and the number of files minus 1
int randomIndex = -1;
do
{
randomIndex = random.Next(0, files.Length);
} while (usedRandomNumbers.Contains(randomIndex));

usedRandomNumbers.Add(randomIndex);

// Return the file path at the random index
return files[randomIndex];
}
else
{
UpdateRichTextBox("Folder path for \"random Files Path\" not found!");
return "null";
}
}
19 replies
CC#
Created by Meistro on 4/24/2023 in #help
❔ Random take a File from a Folder
ok thank you guys. So my code is completly wrong or is anything I could add to it so it those what you said ? xD
19 replies
CC#
Created by Meistro on 4/18/2023 in #help
❔ multithreading with Tasks
ah kk
127 replies
CC#
Created by Meistro on 4/18/2023 in #help
❔ multithreading with Tasks
another/next mission for you ! 😛
127 replies
CC#
Created by Meistro on 4/18/2023 in #help
❔ multithreading with Tasks
the close doesnt work 😄 I tryed /close but it doesnt work xD
127 replies
CC#
Created by Meistro on 4/18/2023 in #help
❔ multithreading with Tasks
$close
127 replies
CC#
Created by Meistro on 4/18/2023 in #help
❔ multithreading with Tasks
thx thx
127 replies
CC#
Created by Meistro on 4/18/2023 in #help
❔ multithreading with Tasks
thanks again and have a good week !
127 replies
CC#
Created by Meistro on 4/18/2023 in #help
❔ multithreading with Tasks
ok thx
127 replies
CC#
Created by Meistro on 4/18/2023 in #help
❔ multithreading with Tasks
is it ok if I delete the code I posted above ?
127 replies
CC#
Created by Meistro on 4/18/2023 in #help
❔ multithreading with Tasks
🙂
127 replies
CC#
Created by Meistro on 4/18/2023 in #help
❔ multithreading with Tasks
realy ! thank you very much !!!!
127 replies
CC#
Created by Meistro on 4/18/2023 in #help
❔ multithreading with Tasks
this dumb method took me a whole day and I did not fix anything alone 😄
127 replies
CC#
Created by Meistro on 4/18/2023 in #help
❔ multithreading with Tasks
yeah ! 😄 realy Happy thank you !
127 replies
CC#
Created by Meistro on 4/18/2023 in #help
❔ multithreading with Tasks
i mean "72,09682680000013 seconds" is not correct but I will fix this anyways
127 replies
CC#
Created by Meistro on 4/18/2023 in #help
❔ multithreading with Tasks
127 replies
CC#
Created by Meistro on 4/18/2023 in #help
❔ multithreading with Tasks
I think it worked
127 replies
CC#
Created by Meistro on 4/18/2023 in #help
❔ multithreading with Tasks
did this helped a bit ? or is it too much ? I know its confusing but I thought it might clarify things 😄
127 replies