Decompile winform resource files

Source: Internet
Author: User

After the winform program is decompiled by. Net reflector, the. Resources file is not easy for vs recognition and cannot be re-compiled. A simple tool is provided here to convert the. Resources file into a. resx file. Batch conversion is also supported. Select multiple files for one-time browsing. After the files are generated, all. resx files are placed under the resx folder. After the. resx file is generated, it must be copied to the target file of the corresponding. CS file at the same level, and Vs will be automatically associated. Then you can make the corresponding modifications and recompile the files.

Here I try to be a simple tool for learning and testing my own program. Of course you can try to decompile others. net Program, first decompile with reflector, and then use this tool to convert resource files. However, I do not support decompiling others' things. After all, we must respect others' labor achievements and protect intellectual property rights. For more information, see the following interface.

The program interface is as follows:

Select multiple files

Shows the successful conversion:

 

The program code is as follows:

View code

Private void btnok_click (Object sender, eventargs E)
{
String basepath = string. empty;
String sfile = string. Empty; // file name without a path
String newfold = "resx"; // new folder name
String savepath = string. empty;
Int Len = 0;
Int Index =-1;
String strresx = string. empty;
If (files! = NULL & files. length> 0)
{
Sfile = files [0];
Index = sfile. lastindexof ("\\");
Basepath = sfile. substring (0, index); // base path
Savepath = string. Format ("{0 }\{ 1}", basepath, newfold );
If (! System. Io. Directory. exists (savepath ))
{
Directory. createdirectory (savepath );
}
Resourcereader reader = NULL;
Resxresourcewriter writer = NULL;
Foreach (string strresources in files)
{
// Strresx = sfile. Replace (". Resources", ". resx ");
Sfile = strresources;
Index = sfile. lastindexof ("\\");
Len = sfile. length;
If (index>-1 & Len> index)
{
Strresx = sfile. substring (index + 1, len-index-1). Replace (". Resources", ". resx ");
}
Strresx = string. Format ("{0 }\{ 1}", savepath, strresx );
Reader = new resourcereader (strresources );
Writer = new resxresourcewriter (strresx );
Foreach (dictionaryentry en in Reader)
{
Writer. addmetadata (EN. Key. tostring (), en. value );
}
If (reader! = NULL)
{
Reader. Close ();
}
If (writer! = NULL)
{
Writer. Close ();
}
}
MessageBox. Show ("converted resource file conversion succeeded", "system prompt ");
Txtresources. Text = string. empty;
}
Else
{
MessageBox. Show ("The resource file to be converted cannot be blank", "system prompt ");
}

// String strresources = this.txt resources. text;
// String strresx = this.txt resx. text;
// If (string. isnullorempty (strresources) | string. isnullorempty (strresx ))
//{
// Return;
//}
// Resourcereader reader = new resourcereader (strresources );
// Resxresourcewriter writer = new resxresourcewriter (strresx );

// Foreach (dictionaryentry en in Reader)
//{
// Writer. addmetadata (EN. Key. tostring (), en. value );
//}
// Reader. Close ();
// Writer. Close ();
}

Download the source code of the entire project as follows:

/Files/CGLI/convertresource.rar

Reprinted Please retain the original address http://www.cnblogs.com/cgli/archive/2011/04/28/2032262.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.