UnauthorizedAccessException

B

Beringer

Hello,

Until recently, I had been developing on an XP machine.
Updated to Vista as the development environment and now
when I try to access a file that I need to load I get an

UnauthorizedAccessException

Pardon, my ignorance but what is different in Vista security wise
that would prevent me from accessing a file? I am the only user of
this PC and have admin privliges. It doesn't seem to matter where the
file is located - either in my current "users" subfolder or in a "public"
subfolder.
And I have made sure the "read-only" attribute isn't set.

Thanks in advance.
 
M

Mr. Arnold

Beringer said:
Hello,

Until recently, I had been developing on an XP machine.
Updated to Vista as the development environment and now
when I try to access a file that I need to load I get an

UnauthorizedAccessException

Pardon, my ignorance but what is different in Vista security wise
that would prevent me from accessing a file? I am the only user of
this PC and have admin privliges. It doesn't seem to matter where the
file is located - either in my current "users" subfolder or in a "public"
subfolder.
And I have made sure the "read-only" attribute isn't set.

I take it that you don't know about Run As Administrator means on Vista. In
some cases, even an account with Admin rights on Vista is locked down to
Standard user rights and rights of the Admin must its privileges escalated
when doing things or running programs on Vista. You have to start the VS
2005 or whatever you're using with Run As Administrator, which can be set on
and exe or a short-cut pointing to the exe.

<http://technet2.microsoft.com/Windo...8514-4c9e-ac08-4c21f5c6c2d91033.mspx?mfr=true>

<http://www.devx.com/VistaSpecialReport/Article/33856/1954?pf=true>


And sometimes on Vista you have to take account ownership of a file too.
 
B

Beringer

Thank you for your reply.

I did set my VS to run as Admin and still have the same issue.
This is quite frustrating.
I can open and use my simple text file I'm trying to load in notepad.

Eric
 
B

Beringer

Thank you for a response.

I have tried reading the file from:

C:\Users\username\documents....
as well as
C:\Users\public....

The file is a simple text file and I can open it using Notepad.

I really don't understand why I can't access it from my application.

Eric
 
W

Willy Denoyette [MVP]

What's the exact exception message thrown on you?
Are you sure you are writing to the home path?
Did you inspect the eventlog to see who's accessing the file and why it's
failing?
Did you upgrade from XP, or is this a fresh install?

Willy.
 
B

Beringer

One other possibility I thought of is the application I'm writing isn't
loading
the file but another component is that is located in DLL.
Do I have to provide permision for the DLL to access this file?
I checked the permisions for this DLL and it appears my
settings are such to provide "full control"

Thanks again
 
B

Beringer

I found out what was wrong. Code works as expected.
The user is the one doing things wrong.

Thanks for all the feedback. Much appreciated.
 

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