Laufzeitverhalten einer (File)Exception beeinflussen

T

Thiemo Ripper

Hallo Ng,

folgendes Stückchen Programm:
try
stmFile = System.IO.File.Open(txt_Convert.Text,
IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
objCRC = New DesktopDll.FileOp.CRC32
intResult = objCRC.GetCrc32(stmFile)
stmFile.Close()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation + MsgBoxStyle.OKOnly)
End Try

Meine Frage:
Kann ich irgendwie darauf Einfluss nehmen, wie lange es dauert, bis die
Exception geworfen wird, dass die Datei nicht existiert? Einen wie auch
immer gearteten Timeout zu verringern....momentan benötigt Windows ca 8
Sekunden - das ist ein bissl lang....

Ich bin mir bewusst, dass ich den Code dahingehend optimieren kann, dass ich
per FileInfo vorher auf die Existenz abprüfen kann. Deswegen mehr so die
grundsätzlich Frage, ob ich an der Stelle eine Chance habe, die in etwa
folgendes möglich macht:
"Schau 0,5sek, ob du die Datei findest und wenn nicht, dann wirf die
Exception"

Das würde mir das Leben auch an anderen Stellen evtl etwas vereinfachen :)


Gruß
Thiemo
 
T

Thiemo Ripper

sorry for hitting wrong group...thus should haven gone into the german
one...arrgs :(
 
M

m.posseth

as far as i know of you can`t set the time when the exception will be thrown

well indeed i would first check if the file exists

system.IO.File.Exists ()

regards

Michel Posseth [MCP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top