This Program should rename .txt Files to .txtok. In my Test-Directory i created ~10 Textfiles.
At runtime, a FileNotFoundException was thrown. The missing File was a File which was already renamed in a previous Thread.
It seems that multiple Threads have started in one Loop-Iteration!?
static void Main(string[] args)
{
foreach (String s in Directory.EnumerateFiles(@"C:\Test", "*.txt", SearchOption.TopDirectoryOnly))
{
new Thread(() =>
{
File.Move(s, s + "ok");
}).Start();
}
Console.ReadKey();
}
Does anybody had a Problem simmilar to this?
Thanks