usingSystem;usingSystem.Collections.Generic;usingSystem.Collections.ObjectModel;usingSystem.IO;usingSystem.Linq;usingSystem.Net;usingSystem.Net.Http;usingSystem.Text;usingSystem.Threading.Tasks;usingWindows.Storage;usingWindows.UI.Popups;usingCoreFtp;usingCoreFtp.Infrastructure;namespaceFrance_Vacances.Methods{publicstaticclassOnlineOperations{publicstaticstringDownloadString(stringfileUri){varuri=newUri(fileUri);varhttpClient=newHttpClient();// Always catch network exceptions for async methodstry{varresponse=httpClient.GetAsync(uri).Result;if(response.IsSuccessStatusCode){// by calling .Result you are performing a synchronous callvarresponseContent=response.Content;// by calling .Result you are synchronously reading the resultstringresponseString=responseContent.ReadAsStringAsync().Result;returnresponseString;}}catch(Exceptionex){MessageDialogmessageDialog=newMessageDialog(ex.Message);messageDialog.ShowAsync();}// Once your app is done using the HttpClient object call dispose to // free up system resources (the underlying socket and memory used for the object)httpClient.Dispose();returnnull;}publicstaticasyncvoidDownloadFile(stringfileUri,stringfileLocation,stringfileName){HttpClienthttpClient=newHttpClient();// Always catch network exceptions for async methodstry{Uriuri=newUri(fileUri);StorageFolderlocalFolder=awaitApplicationData.Current.LocalFolder.CreateFolderAsync(fileLocation,CreationCollisionOption.OpenIfExists);StorageFilefile=awaitlocalFolder.CreateFileAsync(fileName,CreationCollisionOption.ReplaceExisting);byte[]buffer=awaithttpClient.GetByteArrayAsync(uri);// Download fileusing(Streamstream=awaitfile.OpenStreamForWriteAsync())stream.Write(buffer,0,buffer.Length);// Save}catch(Exceptionex){MessageDialogmessageDialog=newMessageDialog(ex.Message);messageDialog.ShowAsync();}// Once your app is done using the HttpClient object call dispose to // free up system resources (the underlying socket and memory used for the object)httpClient.Dispose();}publicstaticasyncvoidUploadToFtp(stringfileName,stringremoteLocation){//Configuration for FTP clientFtpClientConfigurationftpClientConfiguration=newFtpClientConfiguration{Host="ftp.retroth.ml",Port=21,Username="u157773980.3duser",Password="ftppass67",BaseDirectory=remoteLocation};FtpClientftpClient=newFtpClient(ftpClientConfiguration);try{StorageFilefile=awaitApplicationData.Current.LocalFolder.GetFileAsync(fileName);byte[]buffer=File.ReadAllBytes(file.Path);awaitftpClient.LoginAsync();using(Streamstream=awaitftpClient.OpenFileWriteStreamAsync(fileName))stream.Write(buffer,0,buffer.Length);awaitftpClient.LogOutAsync();}catch(Exceptionex){MessageDialogmessageDialog=newMessageDialog(ex.Message);awaitmessageDialog.ShowAsync();}ftpClient.Dispose();}publicstaticasyncTask<ReadOnlyCollection<FtpNodeInformation>>GetListOfFiles(stringremoteLocation){//Configuration for FTP clientFtpClientConfigurationftpClientConfiguration=newFtpClientConfiguration{Host="ftp.retroth.ml",Port=21,Username="u157773980.3duser",Password="ftppass67",BaseDirectory=remoteLocation};FtpClientftpClient=newFtpClient(ftpClientConfiguration);try{awaitftpClient.LoginAsync();ReadOnlyCollection<FtpNodeInformation>filesCollection=awaitftpClient.ListFilesAsync();awaitftpClient.LogOutAsync();returnfilesCollection;}catch(Exceptionex){MessageDialogmessageDialog=newMessageDialog(ex.Message);awaitmessageDialog.ShowAsync();}ftpClient.Dispose();returnnull;}}}