不用指定明确路径,使其在程序内部,这样只要程序文件完整,就不需要外部文件。是用resources吗,具体怎么办

解决方案 »

  1.   

    resources也可以还可以把图片作为嵌入的资源加到项目里,然后直接用这个嵌入的资源文件
      

  2.   


     /// <summary>
            /// 根据文件名称,从"ZJGL.InitResources.dll“中获取文本
            /// </summary>
            /// <param name="filename"></param>
            /// <returns></returns>
            private static string GetStringFromInitResources(string filename)
            {            
                string sPath = Assembly.GetExecutingAssembly().CodeBase;
                int n = sPath.LastIndexOf("/");
                sPath = sPath.Substring(0, n);
                Assembly a = Assembly.LoadFrom(Path.Combine(sPath,InitResourcesDLL));            Stream strm = a.GetManifestResourceStream( InitResourcesProjectName + "." + filename);            ....   
            }
      

  3.   

    打开项目中的Properties--》Resources.resx-->添加资源
    就可以了!