Can write to a txt file but not see if it exists

22-degrees

Well-known member
Joined
Feb 11, 2012
Messages
156
Location
South East Ireland
Programming Experience
1-3
A friend of mine has reported a piece of software that I made for him has all of a sudden begun to crash on a regular basis at the same point..

I have narrowed this issue down to the following..

In form_load, the prog checks if a txt file exists, and if yes, reads a bunch of setting data from it to apply to the main prog. If no, it creates the file and prompts the user to manually set all the paramters himself.

Luckily he has vs.net so I was able to help with the debugging.. A breakpoint on the line:

VB.NET:
If My.Computer.FileSystem.FileExists("C:\xxxx\Data.txt") Then

is triggered, but F8 (Step Into) exits the entire sub rather than returning the result of the statement (i.e yes it exists -> do the following) or (no it doesnt exist, create it and do something else)

Is there any reason why something like this would happen? I asked was he using any new software of late or running a defrag or virus scan to which he replied no x 3

It is puzzling me here because i have the exact same program on my PC and it runs just fine.. i even sent him my exact version and it still crashed on his machine due to the missing code that was being skipped as a result of the anomaly..

He claims he was not messing with the data folder but i think it is very strange that his settings can be written to the file, but the existence of the file cannot be verified.

Any thoughts?
 
My immediate thought is that the user doesn't have permission to access the specified folder. One issue here is the fact that, on 64-bit systems, exceptions thrown in the Load event handler are simply swallowed, so you're not getting to see the original issue. It's wise to always wrap an exception handler around all I/O operations anyway but here especially. If you can wrap the contents of the Load event handler in a Try block then you'll be able to Catch the original exception and hopefully diagnose the issue.
 
Thanks for the swift reply.

I was thinking about permissions but it didnt explain why it was working just fine up to and inculding an hour ago and then.. not

I didnt like how 64 interacted with vb and a few other proggy's so i switched to 32 but yes he is on 64..

I'll work in the try block and see if I can pin point the problem.. His head is wrecked at the moment and he has gone to cool off so i wont be able to follow up on this until later today i expect.
 
Back
Top