我正在尝试使用以下语法读取XML文件并将其存储在datatable中:
dtServerNames.ReadXml("ServerPaths.xml");
Could not find file 'c:\documents and settings\590000\my documents\visual studio 2010\Projects\EasyDeployer\EasyDeployer\bin\Debug\ServerPaths.xml'该文件被放置在应用程序的根目录中,即位于以下路径:
c:\documents and settings\590000\my documents\visual studio 2010\Projects\EasyDeployer\EasyDeployer但是,它正在bin foler中查找文件。即使我给出了完整路径,它也是说文件不存在。
下面是我所指的XML文件:
<?xml version="1.0" encoding="utf-8" ?>
<ServerList>
<ServerName>
Dev Server 1
</ServerName>
<ServerPath>
C:\Avinash\Dev1
</ServerPath>
<ServerName>
Dev Server 1
</ServerName>
<ServerPath>
C:\Avinash\Dev2
</ServerPath>
</ServerList>我已经正确地检查了文件的存储位置。所以,我找不到为什么会发生这种情况..
你知道为什么会发生这种情况吗?我可以做出哪些改变来让它发挥作用?
我给出的完整路径如下:
dtServerNames.Read(" c:\\documents and settings\\590000\\my documents\\visual studio 2010\\Projects\\EasyDeployer\\EasyDeployer");发布于 2013-09-20 17:05:55
如果你想像这样读文件,你必须把你的文件放在bin文件夹中,否则你不能像这样读它。
如果你想把文件放在bin文件夹以外的地方,你需要给出该文件夹的完整路径。
如果给出完整路径,那么只需这样做
System.Xml.XmlTextReader reader =
new System.Xml.XmlTextReader(@"C:\Projects\projectname\XMLFile1.xml");https://stackoverflow.com/questions/18912765
复制相似问题