C#: How do I avoid the UAC Prompt?

lozina

Lifer
Sep 10, 2001
11,709
8
81
Well first let me just say I am a Windows XP user and I have no experience using Vista or Windows 7. I really do not understand their file protection schemes.

But I have a project I am developing which people download and it needs to save certain things to file, which the program should then be able to load anytime it is run again.

this has always worked fine until users with the newer OS's started reporting problems accessing that file on their system. First it would crash the PC, and then with some research I use this path:
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

to store that file.

But while at least it does not crash anymore I do have people reporting that they get a "UAC prompt" and i guess this is some kind of nag, at least it is nagging to them. So I would like to know how can I store my file while avoiding this nonsense?

What system property would provide me a "safe" path to work with?
 

sourceninja

Diamond Member
Mar 8, 2005
8,805
65
91
You are probably writing the file in a location that requires admin privileges. Stick the file somewhere else (like documents and settings)
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
13
81
www.markbetz.net
You should give some more information. You imply that people download an app, but what's that mean? Is it a Silverlight app? A WPF click-once install? A downloaded Winforms applications? These all have different rules regarding what happens when they try to write the local disk.
 

lozina

Lifer
Sep 10, 2001
11,709
8
81
You should give some more information. You imply that people download an app, but what's that mean? Is it a Silverlight app? A WPF click-once install? A downloaded Winforms applications? These all have different rules regarding what happens when they try to write the local disk.

lol - I totally forgot to mention that

It is a Windows Forms client side app. An EXE.

IsolatedFileStorage - I read something about this. I guess I will try this as a last resort since it would make things more complicated. I would prefer if I could just get a safe path to work with so I dont have to modify all my code too much with reading.writing to the isolatedfilestorage
 

nickbits

Diamond Member
Mar 10, 2008
4,122
1
81
Are you trying to use the root of ApplicationData or making a subfolder in there? Try a subfolder if you're not doing that right now.
 

lozina

Lifer
Sep 10, 2001
11,709
8
81
Are you trying to use the root of ApplicationData or making a subfolder in there? Try a subfolder if you're not doing that right now.

Good point. I might actually be trying the root! (codes at home so I'll check later)
 

sreemagesh

Junior Member
Sep 27, 2017
1
0
1
I know this is old thread, I have the similar issue. Did anyone resolved the UAC prompt issue for a .Net EXE file to run without UAC prompt
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
I know this is old thread, I have the similar issue. Did anyone resolved the UAC prompt issue for a .Net EXE file to run without UAC prompt

It's better to start a new thread unless it is really the same issue of needing to write to protected folders.

To run a .Net EXE without a UAC prompt, you need to set your project to not require administrator rights. Then you will only see either a UAC prompt or error when you try to access a resource that requires those rights.