C#无法将内嵌资源文件导出到硬盘
运行后仅输出了0KB的文件,资源文件都已设置为内嵌,存于Client文件夹内返回的Stream也不为nullpublicStreamGetResourceFile(str...
运行后仅输出了0KB的文件,资源文件都已设置为内嵌,存于Client文件夹内
返回的Stream也不为null
public Stream GetResourceFile(string name,bool isNamespaceDefined = false)
{
Type type = MethodBase.GetCurrentMethod().DeclaringType;
string start = "";
if (!isNamespaceDefined)
start = type.Namespace + ".Client.";
return Assembly.GetExecutingAssembly().GetManifestResourceStream(start + name);
}
Stream fileStream = GetResourceFile(file,true);
FileStream fs = new FileStream(label8.Text + @"\" + location, FileMode.Create, FileAccess.Write);
fileStream.CopyTo(fs);
fs.Close(); 展开
返回的Stream也不为null
public Stream GetResourceFile(string name,bool isNamespaceDefined = false)
{
Type type = MethodBase.GetCurrentMethod().DeclaringType;
string start = "";
if (!isNamespaceDefined)
start = type.Namespace + ".Client.";
return Assembly.GetExecutingAssembly().GetManifestResourceStream(start + name);
}
Stream fileStream = GetResourceFile(file,true);
FileStream fs = new FileStream(label8.Text + @"\" + location, FileMode.Create, FileAccess.Write);
fileStream.CopyTo(fs);
fs.Close(); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询