VS按钮功能添加
写资源文件到指定目录:
private void button1_Click(object sender, EventArgs e)
{
// 获取程序运行目录
string appDir = Application.StartupPath;
// 拼接目标目录:程序目录\data\cs
string targetDir = Path.Combine(appDir, "data", "cs");
// 自动创建文件夹,文件夹已存在不会报错
Directory.CreateDirectory(targetDir);
// 拼接保存的完整路径
string pathA = Path.Combine(targetDir, "a.bmd");
string pathB = Path.Combine(targetDir, "b.bmd");
// 从resx资源读取byte数组写入磁盘,文件存在直接覆盖
File.WriteAllBytes(pathA, Properties.Resources.a);
File.WriteAllBytes(pathB, Properties.Resources.b);
MessageBox.Show("成功释放 a.bmd、b.bmd 到 data\\cs 目录!");
}
发布时间: