本文介绍了从两个项目形式相同的解决方案访问相同的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!

我正在Windows应用程序上工作.我有一个用于配置的xml文件,在同一个解决方案中添加了两个项目,我想使用相对路径从两个项目访问相同的xml文件.我该怎么做

我有xml文件名TeacherCongig.xml,已在第二个项目中将此文件添加为链接,并且我正在使用
此代码用于访问链接的文件

字符串appPath = Path.GetDirectoryName(Application.ExecutablePath);
ds.ReadXml(appPath +"\\ AppConfig \\ TeacherConfig.xml");

提供未找到的异常文件.



解决方案



Hi!

I am working on windows application . I have an xml file for configuration ,I have added two project in the same solution ,I want to access the same xml file from the both project by using relative path . How I can do this

I have xml file name TeacherCongig.xml, I have added this file as a link in the second project and i am using
this code for accessing the linked file

string appPath = Path.GetDirectoryName(Application.ExecutablePath);
ds.ReadXml(appPath + "\\AppConfig\\TeacherConfig.xml");

give exception file not found.



Please help me!

解决方案




这篇关于从两个项目形式相同的解决方案访问相同的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 18:32