winfrom中,嵌入的资源文件路径,并读取txt文件

winfrom中,嵌入的资源文件路径,并读取txt文件_第1张图片

/// <summary>
        /// sql分页存储过程
        /// </summary>
        private void MadeSqlProcdure(string path)
        {
            StreamWriter sw = File.CreateText(path + "SqlPageProcdure.sql");
            string strProcdure = this.getStringResource("txtpemplate.SqlProcdure.txt");
            sw.Write(strProcdure);
            sw.Close();
            sw.Dispose();
            sw = null;
        }
        
        /// <summary>
        /// 读取嵌入的模板资源文件
        /// </summary>
        private string getStringResource(string name)
        {
            System.Reflection.Assembly asm = this.GetType().Assembly;
            //在这个文件中列出的所有资源    
            //asm.GetManifestResourceNames()
            name = this.GetType().Namespace + "." + name;
            System.IO.Stream strm = asm.GetManifestResourceStream(name);
            return new System.IO.StreamReader(strm, System.Text.Encoding.Default).ReadToEnd();
        }


你可能感兴趣的:(winfrom中,嵌入的资源文件路径,并读取txt文件)