UnauthorizedAccessException when reading files... BUT....


S

Sonnich Jensen

Hi

I have made this programme, which behaves in some funny ways

The line is question is:

string[] lines = System.IO.File.ReadAllLines(FFilename + ".db3");

When the exe incl data files are copied to a new computer - it will cause a System.UnauthorizedAccessException error when accessign the file.
There is a try-catch which does not catch it.

If I run is "As admin" it will work
After that I can run it normally after that it will work as nothing has ever been wrong.

When running it from the IDE and debugging it it will work as there is not problem.

So only when copied and run _until_ once as admin it will fail

I can add:
File.SetAttributes(FFilename + ".db3", FileAttributes.Normal);

but will that be a sure way for the future (I am out of computers to test on)
 
Ad

Advertisements

S

Sonnich Jensen

There is a try-catch which does not catch it.
maybe it does.... if there are similar problems to create or expand the log file....?
 

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