473,385 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

UnauthorizedAccessException in Windows Vista

Hi all!

I developed a self updating application (Windows Forms). When there is a new
version, I have to copy it to the directory that it was previously installed.

If the application is installed in another directory outside "\Program
Files", it is working well.

The problem is that if the application is installed in "\Program
Files\Product", where I have an UnauthorizedAccessException when I start
copying the new version (I am using File.Copy()). Is there a way to copy
files to this directory?

Thank you,
Vanessa
Jul 18 '08 #1
2 2148
Vanessa,

Well, it is more than likely that your user that is copying the files
doesn't have access, since it is the program files directory. They have to
be given access, and even then, they probably have to validate the action
through UAC on Vista (unless it is disabled).

Basically, there is nothing you can (or should) do in code if your user
doesn't have rights. You basically should catch the error, and inform the
user that they don't have the appropriate permissions.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Vanessa" <Va*****@discussions.microsoft.comwrote in message
news:F0**********************************@microsof t.com...
Hi all!

I developed a self updating application (Windows Forms). When there is a
new
version, I have to copy it to the directory that it was previously
installed.

If the application is installed in another directory outside "\Program
Files", it is working well.

The problem is that if the application is installed in "\Program
Files\Product", where I have an UnauthorizedAccessException when I start
copying the new version (I am using File.Copy()). Is there a way to copy
files to this directory?

Thank you,
Vanessa
Jul 19 '08 #2
Hi Vanessa,

Nicholas is right. UAC is preventing your application from writing to such
folders. One thing you can do is to make your application download a small
program (an updater, downloads update, attempts copy) which has a UAC-aware
manifest. You will execute the program and because of the manifest users
with administrative access will be able to finish the update. Otherwise,
catch the exception.

You can read about the UAC Manifest and .NET code at
http://blogs.msdn.com/shawnfa/archiv...06/568563.aspx

Best Regards,
Stanimir Stoyanov | www.stoyanoff.info

"Vanessa" <Va*****@discussions.microsoft.comwrote in message
news:F0**********************************@microsof t.com...
Hi all!

I developed a self updating application (Windows Forms). When there is a
new
version, I have to copy it to the directory that it was previously
installed.

If the application is installed in another directory outside "\Program
Files", it is working well.

The problem is that if the application is installed in "\Program
Files\Product", where I have an UnauthorizedAccessException when I start
copying the new version (I am using File.Copy()). Is there a way to copy
files to this directory?

Thank you,
Vanessa
Jul 20 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Hal 9000 | last post by:
In c# we have a function that creates a virtual directory in IIS 6.0 using DirectoryServices API. The code looks like this: // log in to IIS DirectoryEntry rootDir = new...
7
by: Peter Afonin | last post by:
Hello, I'm using this code to access a network share from an asp.net page: Dim dir As DirectoryInfo = New DirectoryInfo("\\10.0.0.150\FormLib\") Dim files() As FileInfo = dir.GetFiles("*.eps")...
4
by: Bruce | last post by:
I am developing an ASP.NET web service application. It works fine on my WinXP Prof development machine. But when I send it to a Windows Server 2003 system I get the following error (attached...
0
by: masago | last post by:
Hi....how are you ?? they can help me to solve this problem ?? Access to the path = "c:\windows\microsoft.net\framework\v1.1.4322\Temporary ASP.NET = Files\reports\06639073\bbab30a7" is...
12
by: Lucas Tam | last post by:
I have a very simple loop: If (Directory.Exists(tempDirectory)) Then Try Dim Files() As String = Directory.GetFiles(tempDirectory) 'Clear out directory For Each Filename As String In Files...
0
by: nime | last post by:
I've got a problem. I cannot debug my app. which one contains WebBrowser control. I found a resolution but it's for an ASP related problem. I couldn't find a correct "user" to give permisson then...
6
by: j2ee.singh | last post by:
Hi, I'm looking to buy a new laptop primarily to learn & practice .NET and C#. My Question is: Is there any requirement for .NET and C# in terms of the following Operating Systems: -...
2
by: =?Utf-8?B?Qy4gSHVnaGVz?= | last post by:
Hi, I can't figure it out. A piece of code to obtain the Processor ID which has always worked fine, suddenly throws an UnauthorizedAccessException. I have changed absolutely nothing to my code,...
8
by: imukai | last post by:
I have a forms-based authentication application on our intranet - ASP.NET 3.5 (C#). For security purposes there is one specific .aspx file that we have enabled Integrated Windows Authentication...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.