Click here to Skip to main content
15,914,594 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: The format of the file 'system' is invalid. Pin
Dave Kreskowiak4-Mar-05 3:21
mveDave Kreskowiak4-Mar-05 3:21 
GeneralStreamReader constructor fails in FileWatcher event handler Pin
2-Mar-05 4:27
suss2-Mar-05 4:27 
GeneralRe: StreamReader constructor fails in FileWatcher event handler [Edit] Pin
Mitch F.2-Mar-05 6:32
Mitch F.2-Mar-05 6:32 
GeneralRe: StreamReader constructor fails in FileWatcher event handler [Edit] Pin
skifanatic2-Mar-05 7:00
skifanatic2-Mar-05 7:00 
GeneralRe: StreamReader constructor fails in FileWatcher event handler [Edit] Pin
Mitch F.2-Mar-05 7:53
Mitch F.2-Mar-05 7:53 
GeneralRe: StreamReader constructor fails in FileWatcher event handler [Edit] Pin
skifanatic2-Mar-05 8:33
skifanatic2-Mar-05 8:33 
GeneralRe: StreamReader constructor fails in FileWatcher event handler [Edit] Pin
Dave Kreskowiak2-Mar-05 9:13
mveDave Kreskowiak2-Mar-05 9:13 
GeneralRe: StreamReader constructor fails in FileWatcher event handler [Edit] Pin
skifanatic2-Mar-05 9:59
skifanatic2-Mar-05 9:59 
Dave Kreskowiak wrote:
StreamReader? I must be missing something here. The file is being written to disk by another process, your code tries to read the file when the FileSystemWatcher event fires (which will happen when the file is CREATED, not when it's completely written!) Your code attempts to read a file that is still being written and hasn't been flushed to disk and closed, correct?


Ah...this is a plausible explanation! The first time that the handler gets called I notice that the system appears to load a dll (microsoft.visualbasic.dll). Subsequent iterations of the handler do not result in this dll being loaded. It may well be that the process of loading the dll is sufficient to delay things enough for the file write to complete, and therefore cause the StreamReader constructor to work.

From then on the dll is not loaded (it's already there), so the StreamReader constructor is called sooner, and as Dave points out the file may not be completely written yet, therefore causing the symptoms that I'm seeing.

Interestingly, trying to use read only handle doesn't solve this problem.

Hmm...makes me wonder how to properly use the FileWatcher at all.

Anyway, thanks Dave for pointing out the obvious. I'll now scratch my growing stubble and see if I can figure out a way to make this sucker work!
GeneralRe: StreamReader constructor fails in FileWatcher event handler [Edit] Pin
Dave Kreskowiak2-Mar-05 11:15
mveDave Kreskowiak2-Mar-05 11:15 
GeneralRe: StreamReader constructor fails in FileWatcher event handler [Edit] Pin
skifanatic2-Mar-05 11:47
skifanatic2-Mar-05 11:47 
GeneralRe: StreamReader constructor fails in FileWatcher event handler Pin
Dallas Matthews2-Mar-05 9:28
Dallas Matthews2-Mar-05 9:28 
GeneralTrigger to send an email Pin
Un-Connected2-Mar-05 4:18
Un-Connected2-Mar-05 4:18 
GeneralRe: Trigger to send an email Pin
Mitch F.2-Mar-05 5:55
Mitch F.2-Mar-05 5:55 
GeneralSystem.NullReferenceException: Object reference not set to an instance of an object. Pin
ug39kxt@cs.bham.ac.uk2-Mar-05 3:58
ug39kxt@cs.bham.ac.uk2-Mar-05 3:58 
GeneralRe: System.NullReferenceException: Object reference not set to an instance of an object. Pin
Colin Angus Mackay2-Mar-05 4:25
Colin Angus Mackay2-Mar-05 4:25 
GeneralRe: System.NullReferenceException: Object reference not set to an instance of an object. Pin
ug39kxt@cs.bham.ac.uk2-Mar-05 4:50
ug39kxt@cs.bham.ac.uk2-Mar-05 4:50 
GeneralRe: System.NullReferenceException: Object reference not set to an instance of an object. Pin
ug39kxt@cs.bham.ac.uk2-Mar-05 4:56
ug39kxt@cs.bham.ac.uk2-Mar-05 4:56 
GeneralRe: System.NullReferenceException: Object reference not set to an instance of an object. Pin
Dave Kreskowiak2-Mar-05 7:06
mveDave Kreskowiak2-Mar-05 7:06 
Generalconverting to VB.NET Pin
Lisana2-Mar-05 3:20
Lisana2-Mar-05 3:20 
GeneralRe: converting to VB.NET Pin
Dave Kreskowiak2-Mar-05 3:36
mveDave Kreskowiak2-Mar-05 3:36 
GeneralLatching a Snap-in to components in a windows service. Pin
CSharpBala2-Mar-05 2:54
CSharpBala2-Mar-05 2:54 
GeneralRecordSet and ResultSet Pin
Sumesh V.K2-Mar-05 0:47
Sumesh V.K2-Mar-05 0:47 
GeneralRe: RecordSet and ResultSet Pin
J4amieC2-Mar-05 3:17
J4amieC2-Mar-05 3:17 
GeneralShell the Recycle Bin Pin
AndrewVos1-Mar-05 22:37
AndrewVos1-Mar-05 22:37 
GeneralRe: Shell the Recycle Bin Pin
AndrewVos1-Mar-05 22:49
AndrewVos1-Mar-05 22:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.