CalmSoul
asked on
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
I have a vb.net code which reads from a text file all network locations and then calculated the MD5 hash of those files and then further write hash values to output.txt file ... Program stops working after 500 lines and throw following error ... following is the code and error messages
CODE:
ERRORS:
CODE:
Dim sNames As String() = {"A"}
System.Threading.Tasks.Parallel.For(0, sNames.Count, Sub(i)
For Each line As String In lines
file.Write(MD5(line, 2))
file.Write("@")
file.WriteLine(line)
' i += 1
ProgressBar1.Value += 1
Next
End Sub)
file.Close()
ERRORS:
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll
The program '[11208] WindowsApplication1.vshost.exe' has exited with code 0 (0x0).
First chance exceptions are difficult to find a reason for, and are not thrown, and in my opinion they can be ignored.
ASKER
@Bob, but program stops how can I ignore and proceed in my code?
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
it just prints "60" and nothing happens - no exception ... on output file it just stops writing ...
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
do you close the files afetr they were written? windows applications have a maximum of 512 file handles that can be opened same time. this maximum can be increased to 2048 (programmatically) but it is better to practice a proper closing of your files.
Sara
Sara
ASKER
sarabande:
Interesting, so where should I close them with in the loop after every line write?
Interesting, so where should I close them with in the loop after every line write?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.