简体   繁体   English

如何在Visual Studio项目C#中引用包含的文件

[英]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.

相关问题 如何在内部使用IronPython引用自包含的C#类库项目(Visual Studio 2010) - How to refer self-contained C# class library project with IronPython inside (Visual Studio 2010) Visual Studio 2010:如何引用具有第三方依赖性的C#.Net类库项目 - Visual Studio 2010: How refer to a C# .Net class library project with third part dependencies 如何打开“测试项目”代码文件夹中的文件? (Visual Studio 2008和.NET C#) - How to open a file inside a Test Project code folder? (Visual Studio 2008 and .NET C#) 如何引用添加到Visual Studio项目的json文件 - How to refer to json file added to Visual Studio project 如何将 hex 文件嵌入到 C# Visual Studio 项目中? - How to embed a hex file into a C# Visual Studio project? 如何在Visual Studio C#项目中编译hlsl着色器文件 - How to compile hlsl shader file in Visual Studio C# project 如何使用Visual Studio项目中包含的文件? - How do I use a file included in my visual studio project? 我可以将 windows (.bat ) 文件放在 Visual Studio C# 项目的资源文件夹中吗? - Can I put a windows (.bat ) file inside the resources folder of a Visual studio C# project? 使用EnvDTE API从Visual Studio加载项内部以编程方式将文件添加为C#项目中的链接 - Programmaticaly add file as a link in C# project from inside visual studio add-in using EnvDTE API 在Visual Studio 2010 C#项目中读取链接的xml文件 - Read a linked xml file in Visual Studio 2010 C# project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM