1
I’m doing an application, and at some point it does the following:
Checks if a file that will be created already exists in a directory (output), if it already exists, it sends to the Errors folder, if not, it sends to the output folder.
It gets to a point where the program transfers the file to the errors and Buga folder, saying that the file does not exist. For example, he just transferred the file t(49).png
and he reads the same file again!
Funny it’s only in some cases that he does it .
This is my code :
if (System.IO.File.Exists(entrada + "t (" + i + ").png")) {
string[] datas1 = Spire.Barcode.BarcodeScanner.Scan(@"C:\\QTRACK\\Entrada\\PNG\\t (" + i + ").png");
this.textBox1.Text = datas1[0];
foreach(string code in datas1) {
DirectoryInfo exit = new DirectoryInfo(@"C:/QTRACK/Erro/");
FileInfo[] teste = exit.GetFiles("*.png");
x = teste.Length + 1;
for (c = x; c <= 1000000000; c++) {
if (System.IO.File.Exists(saida + code + ".png")) {
System.IO.File.Move(entrada.ToString() + "t (" + i + ").png", erro + "e" + c + ".png");
} else {
System.IO.File.Move(entrada.ToString() + "t(" + i + ").png", saida + code + ".png");
}
}
}
} else {
}
He makes the mistake of FileNotFoundExecption
, but it was himself who changed the file and is trying to change again.
It’s not because I’m making a billion iterations in the cycle?
– Jorge B.
But how could I do that without those billion interactions ?
– Yuri Ancelmo
I’m inexperienced yet
– Yuri Ancelmo
Are you using some mechanism of thread? Where this code is called?
– Leonel Sanches da Silva