Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.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# 使用C中的相对路径在Internet Explorer中打开xml文档_C#_Xml_Internet Explorer_Relative Path_Filepath - Fatal编程技术网

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方法