C# 使用C中的相对路径在Internet Explorer中打开xml文档
到目前为止,我掌握的代码如下:C# 使用C中的相对路径在Internet Explorer中打开xml文档,c#,xml,internet-explorer,relative-path,filepath,C#,Xml,Internet Explorer,Relative Path,Filepath,到目前为止,我掌握的代码如下: System.Diagnostics.Process.Start("iexplore.exe", "filename.xml"); 它确实启动了InternetExplorer,但URL显示:当然不能显示 xml文件位于bin/Debug文件夹中 string path = System.IO.Path.Combine( System.IO.Directory.GetCurrentDirectory(),
System.Diagnostics.Process.Start("iexplore.exe", "filename.xml");
它确实启动了InternetExplorer,但URL显示:当然不能显示
xml文件位于bin/Debug文件夹中
string path = System.IO.Path.Combine(
System.IO.Directory.GetCurrentDirectory(),
"filename.xml");
System.Diagnostics.Process.Start("iexplore.exe", path);
您应该使用文件开头添加的file:///写入文件的完整路径
您应该使用文件开头添加的file:///来编写文件的完整路径。类似的方法可以工作
string sXmlPath = System.IO.Path.Combine(Application.StartupPath, "filename.xml");
System.Diagnostics.Process.Start("iexplore.exe", sXmlPath);
像这样的东西会有用的
string sXmlPath = System.IO.Path.Combine(Application.StartupPath, "filename.xml");
System.Diagnostics.Process.Start("iexplore.exe", sXmlPath);
问题是相对路径没有提供internet explorer的完整路径,因此我不得不使用以下方法:
System.Diagnostics.Process.Start("iexplore.exe", Path.GetFullPath("filename.xml"));
确保将using System.IO添加到您的程序中。问题是相对路径没有提供到internet explorer的完整路径,因此我不得不使用以下方法:
System.Diagnostics.Process.Start("iexplore.exe", Path.GetFullPath("filename.xml"));
请确保将using System.IO添加到您的程序中。谢谢,但使用相对路径很重要,我刚刚找到了它,并将在下面发布解决方案。使用GetCurrentDirectory方法谢谢,但使用相对路径很重要,我刚刚找到了它,并将在下面发布解决方案。使用GetCurrentDirectory方法