5

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

StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
Chathuranga
  • 113
  • 1
  • 1
  • 10

2 Answers2

10

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);
Quispie
  • 948
  • 16
  • 30
6
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'

Lev
  • 3,719
  • 6
  • 41
  • 56
  • but when it execute it say the file is already there but i remove all files in destination folder but that error comes again – Chathuranga Mar 09 '12 at 17:31