Advertisement
Guest User

Untitled

a guest
Mar 13th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. public string FTPHost = "ftp://xxx.xxx.xxx/myfile.json";
  2. public string FTPUserName = "loginFTP";
  3. public string FTPPassword = "passFTP";
  4.  
  5. public void ImportJSON () {
  6.  
  7. Directory.CreateDirectory(Path.Combine(Application.persistentDataPath, "Backups"));
  8. Debug.Log("On créé le dossier Backup");
  9.  
  10. var FilePath = Path.Combine(Application.persistentDataPath, "Backups");
  11.  
  12. using (WebClient request = new WebClient())
  13. {
  14. request.Credentials = new NetworkCredential(FTPUserName, FTPPassword);
  15. byte[] fileData = request.DownloadData(FTPHost);
  16.  
  17. Debug.Log ("OK GO On sauvegarde le fichier dans Backups");
  18.  
  19. using (FileStream file = File.Create(FilePath))
  20. {
  21. file.Write(fileData, 0, fileData.Length);
  22. file.Close();
  23. }
  24. Debug.Log("Download Complete");
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement