简体   繁体   English

C#WebClient下载一半的dll

[英]c# webclient downloads half of dll

so basically ive been trying to create a program that injects a dll 所以基本上我一直在尝试创建一个注入dll的程序

right now im stuck at the webclient download part because it only downloads basically "half" of my dll 现在我停留在webclient下载部分,因为它基本上只下载我的dll的“一半”

(dll is size is 470 kb but the downloaded dll is only 216 kb) (dll的大小为470 kb,但下载的dll仅为216 kb)

code: 码:

(stole this from stackoverflow) (从stackoverflow偷走了这个)

   public void DownloadFile(string sourceUrl, string targetFolder)
        {
            WebClient downloader = new WebClient();
            // fake as if you are a browser making the request.
            downloader.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0)");
            downloader.DownloadFileCompleted += new AsyncCompletedEventHandler(Downloader_DownloadFileCompleted);
            downloader.DownloadProgressChanged +=
                new DownloadProgressChangedEventHandler(Downloader_DownloadProgressChanged);
            downloader.DownloadFile(new Uri(sourceUrl), targetFolder);
            // wait for the current thread to complete, since the an async action will be on a new thread.
            while (downloader.IsBusy) { }
        }

        private void Downloader_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        {
            // print progress of download.
            metroLabel2.Text = "Downloading: " + e.ProgressPercentage + "%";
        }

        private void Downloader_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            // display completion status.
            if (e.Error != null)
                Console.WriteLine(e.Error.Message);
            else
                metroLabel2.Text = "Ready to Inject!";

            injectbutton.Enabled = true;
        }

//usage //用法

string sourceUrl = "https://www.webiste/mad.dll";
        string targetdownloadedFile = @"C:\\temp\\mad.dll";

        DownloadFile(sourceUrl, targetdownloadedFile);

it was my dll all along 一直是我的dll

thanks everyone for help 谢谢大家的帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM