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.
Mr. Arnold - 19 Mar 2008 04:07 GMT
> Hello,
>
[quoted text clipped - 10 lines]
> 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/WindowsVista/en/library/0d75f774-8514-4c9e-ac08-4c
21f5c6c2d91033.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.
Beringer - 19 Mar 2008 19:17 GMT
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
>> Hello,
>>
[quoted text clipped - 23 lines]
>
> And sometimes on Vista you have to take account ownership of a file too.
RobinS - 19 Mar 2008 16:53 GMT
*Exactly* where are you reading the file from?
Vista is very particular about this sort of thing. You should be able to
read files from the current user's MyDocuments, and down in his
LocalSettings.
For example, we are reading and writing data to a file in a folder we create
inside Environment.SpecialFolder.LocalApplicationData.
On Vista, that would be C:\Users\username\AppData\Local\ourfolder\
In XP, that would be C:\Documents And Settings\username\Local
Settings\Application Data\ourfolder\
Do you have control over where you put the file?
RobinS.
GoldMail.com
> Hello,
>
[quoted text clipped - 12 lines]
>
> Thanks in advance.
Beringer - 19 Mar 2008 19:18 GMT
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
> *Exactly* where are you reading the file from?
>
[quoted text clipped - 31 lines]
>>
>> Thanks in advance.
Willy Denoyette [MVP] - 19 Mar 2008 19:30 GMT
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.
> Thank you for a response.
>
[quoted text clipped - 45 lines]
>>>
>>> Thanks in advance.
Beringer - 19 Mar 2008 19:34 GMT
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
> Hello,
>
[quoted text clipped - 12 lines]
>
> Thanks in advance.
Beringer - 19 Mar 2008 19:54 GMT
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.
> Hello,
>
[quoted text clipped - 12 lines]
>
> Thanks in advance.