net 把指定 URI 的资源下载到本地
程序员文章站
2022-03-04 13:18:51
DirectoryInfo dir = new DirectoryInfo(AppContext.BaseDirectory); var path = dir.FullName + @"tempFile\"; var filePath = path + Guid.NewGuid() + fileNa... ......
directoryinfo dir = new directoryinfo(appcontext.basedirectory); var path = dir.fullname + @"tempfile\"; var filepath = path + guid.newguid() + filename; if (!directory.exists(path)) directory.createdirectory(path); using (webclient client = new webclient()) { // address:从中下载数据的 uri,www.xxxx.com/xx.jpg // filepath:从中下载数据的 uri,c:\\tempfile\\xx.jpg client.downloadfile(address, filepath); }