繁体   English   中英

在C#WPF应用程序中将批处理文件用作资源

[英]Using a batch file as a resource in C# WPF Application

我有一个要从我的资源创建的批处理文件。

我知道这种为.exe文件创建文件的方法:

byte [] resource_bytes = Project.Properties.Resources.exefile;
File.WriteAllBytes(path, resource_bytes);

对于批处理文件,它的工作方式不同。

有人有解决方案吗?

Windows Batch file (bat)是文本文件,请尝试以下操作:

if (!string.IsNullOrEmpty(text))
{
    File.WriteAllText(resourcePath, text);
}
else
{
    MessageBox.Show("The Batch file is empty");
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM