Link to home
Start Free TrialLog in
Avatar of dantheanswerman
dantheanswermanFlag for United States of America

asked on

Can't programmatically copy files VB.net to Windows 7 -"Destination Folder Access Denied"

Experts - Please help!!

Please let me know how to programmatically (VB.NET 3.5 Framework) How to copy a file within a Windows 7 environment.

I have a WinForms app that runs fine in a Windows XP 32 Bit environment.

It updates a winForms application by programmatically coping files to users machines (via UNC) (i.e. "\\MachineName\C$\Program Files\AppName\AppName.exe").

I have a VB.NET 3.5 Framework in VS2008 and am using "System.IO.File.Copy"

As a reminder - The code still works great for a 32Bit Windows XP machine.

When I run the same code and try to copy to the appropriate folder: \\MachineName\C$\Program Files (x86)\AppName\AppName.exe. It will not copy and gives me the following error:

"Access to the path '"\\MachineName\C$\Program Files\AppName\AppName.exe' is denied."

Please let me know how to copy this. FYI- If I manually copy the files it asks me to confirm that I want to copy the files, and warns me in a popup window
User generated image
When I hit "Try Again" it will copy the file.

(On the XP machines it will just copy the file without a warning).

This problem also happens in the regular 64 Bit program file on my (C:\Program Files\AppNameCompilesAs64Bit\AppName.exe).

Again - Please let me know how to programmatically (VB.NET 3.5 Framework) How to copy a file within a Windows 7 environment.
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dantheanswerman

ASKER

Perfect answer ... I was able to elevate permissions and as long as I run as an administrator, it works perfectly!

Thanks - you made my day.

Dan