我想从根文件夹加载dic.xml文件,因为现在我在应用程序中提供了完整路径,但我想从根目录加载文件。
var doc = XDocument.Load(@"D:\anu notes\FYP\LSC 1\LSC 1\LSC\LSC\dic.xml");
Here is what you need:
var rootFolder = System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
var xmlFilePath = rootFolder + @"\dic.xml";
var doc = XDocument.Load(xmlFilePath);
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.