随笔 - 252, 文章 - 13, 评论 - 176, 阅读 - 58万
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

导出resource文件的的资源

Posted on   快乐家++  阅读(619)  评论(1编辑  收藏  举报
写个小工具,方便一次性将resource文件中的资源导出,不然反编译后一个个找,真是太麻烦了。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Resources;
using System.Collections;
using System.IO;

namespace ResExport
{
    class Program
    {
        static void Main(string[] args)
        {
            ResourceReader res = new ResourceReader("MSVirtualEvent.g.resources");//该文件放到bin
            IDictionaryEnumerator dics = res.GetEnumerator();
            while (dics.MoveNext())
            {
                Stream s = (Stream)dics.Value;
                int fileSize = (int)s.Length;
                byte[] fileContent = new byte[fileSize];
                s.Read(fileContent, 0, fileSize);
                FileStream fs;
                string filepath = dics.Key.ToString();
                filepath=Path.Combine("C://",filepath); //保存到指定目录
                filepath = Path.GetFullPath(filepath);
                var   p = Path.GetDirectoryName(filepath);//要创建的目录
                if (!Directory.Exists(p))
                {
                    Directory.CreateDirectory(p);
                }

                FileInfo fi = new System.IO.FileInfo(filepath);
                fs = fi.OpenWrite();
                fs.Write(fileContent, 0, fileSize);
                fs.Close();
            }

            res.Close();

        }
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
历史上的今天:
2013-12-28 c# 可以设置透明度的 Panel 组件
点击右上角即可分享
微信分享提示