I want to write files from my C# resources into a USB drive when it is plugged in. I already got the code working which detects if a USB drive is inserted. The problem I encounter is writing the resource files, here is what I tried:
if (File.Exists(e.Drive + "\autorun.inf") == false ) {
File.Copy(@"Resources\update.ico", e.Drive);
File.Copy(@"Resources\autorun.inf", e.Drive);
}
e.Drive contains the path of the inserted USB stick (e.g F:\). I get an error message:
Could not find a part of the path ‘F:\’.
The second argument to File.Copy cannot be just a folder, you have to supply the complete path.