大家都知道编译后的代码很容易被破译,那么如何保证辛辛苦苦做好的工程不被轻易破译吗?那就选用dotfuscator.exe吧
文件在C:\Program Files\Microsoft Visual Studio 8\Application\PreEmptive Solutions\Dotfuscator Community Edition\dotfuscator.exe

使用
1、打开VS2005。
2、点击dotfuscator,它会提示要求注册,可先不注册。
3、具体设置比较简单,这里不细说了。


原C#代码

        protected void doUpload()
        {
            try
            {
                HttpPostedFile file = this.file1.PostedFile;
                string fileContentType = file.ContentType; //文件类型
                string fileExtension = System.IO.Path.GetExtension(file.FileName).ToLower(); //上传文件的扩展名
                string F_Type = fileExtension.Substring(1, fileExtension.Length - 1);
                string strNewPath = DateTime.Now.ToString("yyyyMMddHHmmssffff") + GetExtension(file.FileName);
                file.SaveAs(Server.MapPath(picServer + strNewPath));
                string FullPath = picServer + strNewPath;
                string jsstr = "";
                jsstr += "parent.uploadsuccess('" + FullPath + "','" + itemID + "');";

                if (fileContentType == "image/bmp" || fileContentType == "image/gif" || fileContentType == "image/pjpeg")
                {
                    if (add2ThumbImg.Checked == true) //设为缩略图
                    {
                            jsstr += "parent.add2ThumbImg('" + F_Type + "','" + FullPath + "');\r\n";
                            jsstr += "parent.setUploadImg('" + F_Type + "','" + FullPath + "');\r\n";

                    }

                }
                if (ChannelType != "Article")
                {
                    jsstr += "parent.addDownUrl('" + ChannelType + "','" + FullPath + "');\r\n";
                }
                else //插入文章内容
                {
                    jsstr += "parent.addUploadItem('" + F_Type + "','/','" + FullPath + "','300');\r\n";
                }
                WriteJs(jsstr);

            }
            catch
            {
                WriteJs("parent.uploaderror();");
            }
        }


混淆后的代码

protected: void __gc* doUpload()
{
    try
    {
        HttpPostedFile __gc* postedFile = this->m->PostedFile;
        String __gc* contentType = postedFile->ContentType;
        String __gc* str2 = Path::GetExtension(postedFile->FileName)->ToLower();
        String __gc* str3 = str2->Substring(1, (str2->Length - 1));
        String __gc* str4 = String::Concat(DateTime::Now->ToString(S"yyyyMMddHHmmssffff"), this->a(postedFile->FileName));
        postedFile->SaveAs(base->Server->MapPath(String::Concat(this->a, str4)));
        String __gc* str5 = String::Concat(this->a, str4);
        String __gc* str6 = S"";
        String __gc* str7 = str6;
        str6 = String::Concat(__gc new String __gc*[6] {
            str7, S"parent.uploadsuccess(\'", str5, S"\',\'", this->b, S"\');"});
        if ((((contentType == S"image/bmp") || (contentType == S"image/gif")) || (contentType == S"image/pjpeg")) && this->l->Checked)
        {
            str7 = str6;
            str7 = String::Concat(__gc new String __gc*[6] {
                str7, S"parent.add2ThumbImg(\'", str3, S"\',\'", str5, S"\');\r\n"});
            str6 = String::Concat(__gc new String __gc*[6] {
                str7, S"parent.setUploadImg(\'", str3, S"\',\'", str5, S"\');\r\n"});
        }
        if (this->g != S"Article")
        {
            str7 = str6;
            str6 = String::Concat(__gc new String __gc*[6] {
                str7, S"parent.addDownUrl(\'", this->g, S"\',\'", str5, S"\');\r\n"});
        }
        else
        {
            str7 = str6;
            str6 = String::Concat(__gc new String __gc*[6] {
                str7, S"parent.addUploadItem(\'", str3, S"\',\'/\',\'", str5, S"\',\'300\');\r\n"});
        }
        this->b(str6);
    }
    catch (Object __gc* obj1)
    {
        this->b(S"parent.uploaderror();");
    }
}