public class downClass1 { public IStorageFile pResultStorageFile; public async Task<IStorageFile> down() { string CountriesFile = "fruit.xml"; StorageFolder InstallationFolder =Windows.ApplicationModel.Package.Current.InstalledLocation; StorageFile file = await InstallationFolder.CreateFileAsync(CountriesFile); BackgroundDownloader ppp = new BackgroundDownloader(); DownloadOperation pDownloadOperation= ppp.CreateDownload(new Uri("https://files.cnblogs.com/gisbeginner/fruit.xml"), file);
await pDownloadOperation.StartAsync(); pResultStorageFile = pDownloadOperation.ResultFile; return pResultStorageFile; } } }///
istorageFile类型可以返回给Task〈istorageFile〉,调用这个方法的时候IstorageFile pDownLoadFile = pdownClass1.down() as IStorageFile; 这样是不行的
public IStorageFile pDownLoadFile;
pDownLoadFile =await pdownClass1.down(),这样就可以了
http://msdn.microsoft.com/en-us/library/hh191443(v=vs.110).aspx#Y749