导出resource文件的的资源

本文介绍了一个简单的小工具,能够批量导出resource文件中的资源,避免了反编译后逐个查找的繁琐过程。通过使用C#编程语言,此工具实现了资源文件的自动读取与导出。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

写个小工具,方便一次性将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();

        }
   

转载于:https://www.cnblogs.com/greystar/archive/2010/07/19/2235291.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值