为什么要加,MSDN上明明说的可以是相对路径,况且System.Window命名空间中的Applistation并没有StartPath属性啊。

解决方案 »

  1.   

    txt文件不应该作为资源文件,你应该将它设置成Content,并设置 Copy if newer
    * None: 此文件不参与编译也不被输出。比如:工程中的文档文件, readme.txt。* Compile: 参与编译并输出。主要是代码文件。* Content: 不参与编译,但会被输出。* Embedded Resource: 此文件被嵌入到主工程生成的DLL或exe中。主要是资源文件。* ApplicationDefinition: 和Page类似,但只用于Silverlight的启动页面(默认是App.xaml)。* Page: Silverligh中所有的usercontrol/page/childwindow xaml都属于"Page” build,其它的build action不能将code behind文件和xaml文件连接起来。* CodeAnalysisDictionary: 自定义的CodeAnalysis字典。(参考http://blogs.msdn.com/b/codeanalysis/archive/2007/08/20/new-for-visual-studio-2008-custom-dictionaries.aspx)* Resource:embeds the file in a shared (by all files in the assembly with similar setting) assembly manifest resource named AppName.g.resources* SplashScreen: Silverlight的欢迎界面。* DesignData: Sample data types will be created as faux types. Use this Build Action when the sample data types are not creatable or have read-only properties that you want to defined sample data values for.* DesignDataWithDesignTimeCreatableTypes: Sample data types will be created using the types defined in the sample data file. Use this Build Action when the sample data types are creatable using their default empty constructor.* EntityDeploy: 适用于Entity框架。
      

  2.   

    为什么要加,MSDN上明明说的可以是相对路径,况且System.Window命名空间中的Applistation并没有StartPath属性啊。
    此处相对的目录是bin\debug文件夹,你要看你的debug文件内有没有这个txt文件
      

  3.   

    为什么要加,MSDN上明明说的可以是相对路径,况且System.Window命名空间中的Applistation并没有StartPath属性啊。
    此处相对的目录是bin\debug文件夹,你要看你的debug文件内有没有这个txt文件
    我恰恰要问的是,txt文件为什么不应该作为资源文件,却要将它将它设置成Content呢?作为资源文件,就嵌入到了程序集中,恐怕更应该访问到的吧
      

  4.   

    那你需要设置它成 Embedded Resource,并设置 Copy if newer
      

  5.   

    http://msdn.microsoft.com/zh-cn/library/aa970494(v=vs.110).aspx
      

  6.   

    大师,我还是没有弄明白哦,你给的链接我其实都是有的,它没有解决我下面的两个问题:1:我楼顶上的代码,txt文件为什么不应该作为资源文件,却要将它将它设置成Content呢?作为资源文件,就嵌入到了程序集中,恐怕更应该访问到的吧
    2:按照你说的,设置为"嵌入的资源",并设置"复制",也确实能找到文件,这又是什么原因呢?设置为"Resource"和"嵌入的资源"又有什么不同呢,二者不都是把文件编译到程序集中去的吗?
      

  7.   

    设为resource的文件,在编译时会参与编译,并嵌入到AppName.g.resources文件内而txt,mp3,video这些文件没必要参与编译