獲取嵌入的資源

//獲取文件流
     string name = MethodBase.GetCurrentMethod().DeclaringType.Namespace;

      Stream stream = Assembly.GetExecutingAssembly().
               GetManifestResourceStream(
                   name + ".update.txt")
//獲取圖片
        /// <summary>
        ///     獲取當前命名空間下嵌入的資源圖片
        /// </summary>
        /// <param name="imagePath">嵌入的圖片資源的路徑</param>
        private Image GetImageFormResourceStream(string imagePath)
        {
            string name = MethodBase.GetCurrentMethod().DeclaringType.Namespace;
            return Image.FromStream(
                Assembly.GetExecutingAssembly().
                    GetManifestResourceStream(
                        name + "." + imagePath));
        }
相關文章
相關標籤/搜索