Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在C#WPF应用程序中将批处理文件用作资源_C#_Wpf_File_Batch File - Fatal编程技术网

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

在C#WPF应用程序中将批处理文件用作资源,c#,wpf,file,batch-file,C#,Wpf,File,Batch File,我想从我的资源中创建一个批处理文件 我知道为.exe文件创建文件的方法: byte [] resource_bytes = Project.Properties.Resources.exefile; File.WriteAllBytes(path, resource_bytes); 对于批处理文件,它的工作方式不同 有人有解决方案吗?windows批处理文件(bat)是文本文件,请尝试以下方法: if (!string.IsNullOrEmpty(text)) { File.Write

我想从我的资源中创建一个批处理文件

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

byte [] resource_bytes = Project.Properties.Resources.exefile;
File.WriteAllBytes(path, resource_bytes);
对于批处理文件,它的工作方式不同


有人有解决方案吗?

windows
批处理文件(bat)
是文本文件,请尝试以下方法:

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

windows
批处理文件(bat)
是文本文件,请尝试以下操作:

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

批处理文件是一个简单的文本文件。批处理文件是一个简单的文本文件。