WebClient download save as the filename substring from url

 static void WebClientDownLoadFileDemo()
        {
            string url = "http://dl.booktolearn.com/ebooks2/computer/gamedevelopment/9781789532050_Learning_C_Unity_2019_4514.pdf";
            string fileName =url.Substring(url.LastIndexOf("/")+1);
            using(WebClient wc=new WebClient())
            {
                wc.DownloadFile(url, fileName);
            }
            Console.WriteLine("Finished!");
        }

 

posted @ 2020-10-23 14:18  FredGrit  阅读(93)  评论(0编辑  收藏  举报