例如,如何从我的资源文件中将文件复制到c:/? 我在What is the file path, as a string, of a file in the application's resources?中发现了类似的问题,但它说“错误2参数2:无法从'byte []'转换为'string'”
这是我当前的代码,它失败了:
System.IO.File.Copy("C:\\", ctest.Properties.Resources.test);
test是文件。
答案 0 :(得分:2)
对于二进制文件:
File.WriteAllBytes("C:\\filename.bin", ctest.Properties.Resources.test);
对于文本文件:
File.WriteAllText("C:\\filename.txt", ctest.Properties.Resources.test);
对于图像资源:
Bitmap bitmap = Resources.MyImageResource;
bitmap.Save("filename.jpg", ImageFormat.Jpeg);