How to copy file to Program Files(86) on Win7? (c# or bash)

can you please give me a hand on this? I have a .dll file say in the folder on my desktop. I need to copy it to c:\Program Files(86)\Program Folder\ directory I've already tried to do "File.Copy" but I can't figure out how to make it work with spaces in the folder names. Tried to put the full address in quotes - like "\"my folder\myfile.dll\"" but it also doesn't work. Tried to write a bash file - but can't figure out how to run it through C#. Pls help. Any solution is appreciated. I also need to "Force Overwrite" if possible.


Try: File.Copy(@"c:\Program Files(86)\Program Folder\mydll.dll", @"C:\mydll.dll");

To force overwrite simply use:

File.Copy(@"c:\Program Files(86)\Program Folder\mydll.dll", @"C:\mydll.dll",true); as per MSDN docs:

public static void Copy(
    string sourceFileName,
    string destFileName,
    bool overwrite


sourceFileName Type: System.String The file to copy.

destFileName Type: System.String The name of the destination file. This cannot be a directory.

overwrite Type: System.Boolean true if the destination file can be overwritten; otherwise, false.

As noted in another answer you may not have appropriate permissions you can try checking this by:

string directoryPath = @"c:\Program Files(86)\Program Folder"; 
bool isWriteAccess = false;
AuthorizationRuleCollection collection = Directory.GetAccessControl(directoryPath).GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount));
foreach (FileSystemAccessRule rule in collection)
if (rule.AccessControlType == AccessControlType.Allow)
isWriteAccess = true;
catch (UnauthorizedAccessException ex)
isWriteAccess = false;
catch (Exception ex)
isWriteAccess = false;
if (!isWriteAccess)//we cant write to location
//handle notifications 
}else {//we can write to the location

Need Your Help

Python/Scrapy: Scraping Nasdaq's data?

javascript python selenium scrapy scrape

I am comfortable scraping most sites with Scrapy, however I have never tried getting dynamic content from javascript and I am running into a lot of arguments in regard to how to start learning.