I am getting a runtime IOException on this code:

Dim OStream As TextOutputStream = TextOutputStream.Create(File)

I examined the File and it is the correct path.
The file exists.
The file is not set to read only.

I also added an exception handler to bottom of the method:

Exception err as IOException dim stack as string = join( err.cleanStack, endOfLine ) MsgBox ("An IO exception occurred saving and INI file. Contact support for assistance. Please contact ErrNum=" + CStr(err.Number) + stack)

But the error handler does not pop up. Is that because I am running the app in debug mode and it is stopping on the line creating the error?

How do I debug what is causing it?
I have browsed a bunch of posts but haven’t found anything that seems to help.

error code? Message in exception?

If you are running in the debugger, when it stops on an exception you can view the exception in the debugger. You can also resume to allow your code to continue which should invoke your exception handler.

You might also want to use a Try…Catch instead of Exception to keep your exception handling code closer to the code it is related with.

Sorry for the delay I was out of town.

The exception just says IOException. In the locals window I can click the IOException and see error number set to 5 with no message with it.

I managed to get a stack trace to pop up and the image for that is at this url:

You cannot create a file that already exists. Did you mean to Open it? Or replace it?


Dim OStream As TextOutputStream = TextOutputStream.Open(File)


if File.Exists then File.Delete
Dim OStream As TextOutputStream = TextOutputStream.Create(File)

This is a library from another developer and after using it for over 3 years this is the first time I’ve had any problems.

The file should already exist and just I am just calling the method .Save on it… which in turn calls this code.
I don’t know why he calls Create on it vs. Open.
I guess I would have to ask him…

What I don’t know is why all of a sudden it is throwing an IOException when it never happened before.

Are you running it on a new OS? They’re getting more finicky about replacing files. It used to be Create would simply overwrite the file. Any more, you have to explicitly delete it.

Right now the issue only occurs on Windows. On Mac the IOException does not occur although I am running an older Yosemite not Sierra.

With more testing i have discovered that the error does not occur if I run my app as administrator. I was trying that just to see if maybe Windows 7 was hammering the app. The file I am writing to is in the windows application roaming support area so don’t know why I would have to run as admin to get that to work.

It’s never been a problem before. I have started turning off all active AV and protection related software to see if they are causing the problem by seeing my app as some malware. I have turned them all off and so far problem still occurs.

Anyone have any other ideas?

Run with administrator -> problem goes away

Without that… get IOException error number 5.

Is it possible an antivirus, antimalware, anti something with microsoft… is blocking app from writing file in the Application Support folder?

Windows 7 is all I have seen this on so far. Does not happen on Mac at all (at least in Yosemite)

With Windows 7, anything is possible. Verify you have correct permissions for the folder where you are writing the file. Can’t hurt to try another location or folder as well.

5 (0x5)
Access is denied.[/quote]

Definitely sounds like munged permissions.

Yes I found that in google.

I have checked permissions on the file, the folder, etc.
I have made sure I don’t have any processes attached to the file.

I have had this occur with a couple of my clients too.

Very baffled…

Check if you are the owner of the file:

Select file --> properties --> security --> advanced

Check if you/xojo belong to one of the groups/persons who are allowed to read/write/adjust the file. If not, you should add yourself to a group or change the owner of the group into your account.

NOTE: You need to be admin of the system to do this!

I am the owner of the file and folder was writable.

I still suspect microsoft or malware bytes or eset or ccleaner or SOMETHING was preventing vs. some problem with my program.

BUT several customers had the same issue. (or if it was MS then they got bit by the same security update).

Don’t know. Still baffled.