我用它来加载一个文件(html_file.html)Resources
//string myFile = "C:\\Users\\...\\Resources\\html_file.html"; // this works
var myFile = Path.GetFullPath("html_file.html"); // this doesn't works
//myFile = myFile.ToString();
//myFile = myFile.Replace(@"\", @"\\");
//MessageBox.Show(myFile);
try
{
Process.Start(myFile);
}
catch (Win32Exception noBrowser)
{
if (noBrowser.ErrorCode == -2147467259)
MessageBox.Show(noBrowser.Message);
}
catch (System.Exception other)
{
MessageBox.Show(other.Message);
}
有人可以告诉我有什么问题吗?
编辑:这有效
Build Action = Embedded Resource
和Copy to Output Directory = Copy always
string myFile = @".\Resources\html_file.html";
但我仍然需要Resources
文件的路径。有什么办法可以在我的.EXE
文件中包含“html_file”?