[英]How to refer to included file inside a visual studio project c#
I have a window form project that use a XSL file to convert a XML file. 我有一个使用XSL文件转换XML文件的窗口表单项目。
When I call the XSL file I use a specific method and I pass it the XML's path: 当我调用XSL文件时,我使用一种特定的方法,并将XML路径传递给它:
myXslTransform.Load("...\\Trasformazione.xsl");
How can I refer to the file included in my project? 如何引用项目中包含的文件? Because when I publish it the other people don't have the same path and the program does not work.
因为当我发布它时,其他人没有相同的路径并且该程序无法正常工作。
For example:
例如:
myXslTransform.Load("MyProject.Trasformazione.xsl");
You can save the path in App.config 您可以将路径保存在App.config中
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
</startup>
<appSettings>
<add key="FilePath" value="...\\MyProject.Trasformazione.xsl" />
</appSettings>
</configuration>
And in Code: 并在代码中:
myXslTransform.Load(System.Configuration.ConfigurationManager.AppSettings.Get("FilePath"));
The other people needs to edit config-File (AppName.exe.Config) 其他人需要编辑config-File(AppName.exe.Config)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.