88using System . IO . Compression ;
99using System . Linq ;
1010using System . Net ;
11- using System . Net . Http ;
12- using System . Threading . Tasks ;
1311using Microsoft . ML . Data ;
1412using Microsoft . ML . TestFrameworkCommon ;
1513
@@ -187,13 +185,13 @@ public static string DownloadImageSet(string imagesDownloadFolder)
187185 string fileName = "flower_photos_tiny_set_for_unit_tests.zip" ;
188186 string url = $ "https://aka.ms/mlnet-resources/datasets/flower_photos_tiny_set_for_unit_test.zip";
189187
190- Download ( url , imagesDownloadFolder , fileName ) . Wait ( ) ;
188+ Download ( url , imagesDownloadFolder , fileName ) ;
191189 UnZip ( Path . Combine ( imagesDownloadFolder , fileName ) , imagesDownloadFolder ) ;
192190
193191 return Path . GetFileNameWithoutExtension ( fileName ) ;
194192 }
195193
196- private static async Task Download ( string url , string destDir , string destFileName )
194+ private static void Download ( string url , string destDir , string destFileName )
197195 {
198196 if ( destFileName == null )
199197 destFileName = Path . GetFileName ( new Uri ( url ) . AbsolutePath ) ; ;
@@ -205,16 +203,7 @@ private static async Task Download(string url, string destDir, string destFileNa
205203 if ( File . Exists ( relativeFilePath ) )
206204 return ;
207205
208- using ( var client = new HttpClient ( ) )
209- {
210- var response = await client . GetAsync ( url ) . ConfigureAwait ( false ) ;
211- var stream = await response . EnsureSuccessStatusCode ( ) . Content . ReadAsStreamAsync ( ) . ConfigureAwait ( false ) ;
212- var fileInfo = new FileInfo ( relativeFilePath ) ;
213- using ( var fileStream = fileInfo . OpenWrite ( ) )
214- {
215- await stream . CopyToAsync ( fileStream ) . ConfigureAwait ( false ) ;
216- }
217- }
206+ new WebClient ( ) . DownloadFile ( url , relativeFilePath ) ;
218207 return ;
219208 }
220209
0 commit comments