简体   繁体   中英

Reading Xml file path from Windows for application

I have my files place in a directory name XMLpackage which is located under the Root of my project At run time i need to read the file by passing the Path. By putting my file in debug folder i was able to read. But in this specific XMLpackage folder i can not read it. How to do this?

Change the file property 'Copy to Output' with value other than 'Do not copy'
To get the file path try,

Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "XMLpackage", "file1.xml");

Try this. Right click the file in Solution Explorer and click on Properties. Change the "Copy to Output Directory" to "Copy Always" as shown in the image.

You can access the file like

 string f = System.IO.File.ReadAllText(@"XMLpackage\TableScripts.xml");

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM