写个小工具,方便一次性将resource文件中的资源导出,不然反编译后一个个找,真是太麻烦了。
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Resources;
usingSystem.Collections;
usingSystem.IO;
namespaceResExport
{
classProgram
{
staticvoidMain(string[]args)
{
ResourceReaderres=newResourceReader("MSVirtualEvent.g.resources");//该文件放到bin
IDictionaryEnumeratordics=res.GetEnumerator();
while(dics.MoveNext())
{
Streams=(Stream)dics.Value;
intfileSize=(int)s.Length;
byte[]fileContent=newbyte[fileSize];
s.Read(fileContent,0,fileSize);
FileStreamfs;
stringfilepath=dics.Key.ToString();
filepath=Path.Combine("C:\\",filepath);//保存到指定目录
filepath=Path.GetFullPath(filepath);
varp=Path.GetDirectoryName(filepath);//要创建的目录
if(!Directory.Exists(p))
{
Directory.CreateDirectory(p);
}
FileInfofi=newSystem.IO.FileInfo(filepath);
fs=fi.OpenWrite();
fs.Write(fileContent,0,fileSize);
fs.Close();
}
res.Close();
}