Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void ExportJSON() {
- string FTPHost = "ftp://xxx.xxxx.xxx/";
- string FTPUserName = "login";
- string FTPPassword = "pass";
- string FilePath;
- if (Application.internetReachability == NetworkReachability.NotReachable) {
- Debug.Log ("Error. Check internet connection!");
- } else {
- try {
- FilePath = Path.Combine (Application.persistentDataPath, "clients.json");
- Debug.Log ("Path: " + FilePath);
- WebClient client = new System.Net.WebClient ();
- Uri uri = new Uri (FTPHost + new FileInfo (FilePath).Name);
- Debug.Log (uri);
- client.UploadProgressChanged += new UploadProgressChangedEventHandler (OnFileUploadProgressChanged);
- client.UploadFileCompleted += new UploadFileCompletedEventHandler (OnFileUploadCompleted);
- client.Credentials = new System.Net.NetworkCredential (FTPUserName, FTPPassword);
- client.UploadFileAsync (uri, "STOR", FilePath);
- } catch {
- Debug.Log ("error");
- }
- }
- }
- void OnFileUploadProgressChanged(object sender, UploadProgressChangedEventArgs e) {
- Debug.Log("Uploading Progress: " + e.ProgressPercentage);
- }
- void OnFileUploadCompleted(object sender, UploadFileCompletedEventArgs e) {
- Debug.Log("File Uploaded");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement