Copy resources from c# pjct to a windows directory

14,599

Solution 1

File.Copy(@"Resources\install.bat", @"C:\directory\install.bat");

note: you should have Resources folder in Debug\bin. (if there isn't one, click on property of install.bat file in Visual Studio solution exprorer and set 'Copy to Output Directory' to 'Copy always'

Solution 2

My project can copy a dll as resource in a directory, maybe this wil work for you:

File.WriteAllBytes(@"C:\filename.extension", Properties.Resources.install);
Share:
14,599

Related videos on Youtube

Chathuranga
Author by

Chathuranga

Updated on June 04, 2022

Comments

  • Chathuranga
    Chathuranga almost 2 years

    how can i copy a file in my project resources to a temp directory using C#

    i have install.bat file in my project resources folder i want to copy this into c:\ directory

  • Chathuranga
    Chathuranga about 12 years
    but when it execute it say the file is already there but i remove all files in destination folder but that error comes again