/// <summary> /// Illustrate of work... /// </summary> public void OtherWork() { // Login to Ge.tt var user = new Gett.Sharing.GettUser(); user.Login("myapikey", "mymail@local", "mypassword"); // Find specefic share Gett.Sharing.GettShare share1 = user.Shares.GetShare("9XwUVrB"); // Create new file on share. Gett.Sharing.GettFile file1 = share1.CreateFile("mybackup.sql"); // Start upload new file file1.UploadFile(@"d:\mysqlbackupdump\today.sql"); // Get all shares with most files count in it ordered var shareWithMostfiles = from share in user.Shares.GetShares() where share.FilesInfo.Length > 0 orderby share.FilesInfo.Length descending select share; // Get all shares with the largeste files var shareWithTheLargestFileSize = from share in user.Shares.GetShares() where share.FilesInfo.Length > 0 orderby share.FilesInfo.Max(f => f.Size) descending select share; // Begin async upload of file Gett.Sharing.GettFile file2 = share1.CreateFile("contacts.sql"); file2.BeginUploadFile(@"d:\mysqlbackupdump\contacts.sql", UploadFileCompleted, file2); // Begin async download of file file1.BeginDownloadFile(@"d:\download\today.sql", file1.EndDownloadFile, null); }
private async void button_Upload_Click(object sender, EventArgs e) { if (listBox_Shares.SelectedItem is Gett.Sharing.GettShare) { var openDialog = new OpenFileDialog { CheckFileExists = true }; if (openDialog.ShowDialog() == DialogResult.OK) { var share = (Gett.Sharing.GettShare)listBox_Shares.SelectedItem; try { Gett.Sharing.GettFile file = await share.CreateFileAsync(System.IO.Path.GetFileName(openDialog.FileName), Properties.Settings.Default.LiveSessionId); var upload = new UploadDownloadProgress(true, openDialog.FileName, file); upload.Show(); } catch (Exception ex) { MessageBox.Show(@"Failed to upload new file '" + openDialog.FileName + @"' to Ge.tt" + Environment.NewLine + @"Exception of type " + ex.GetType() + Environment.NewLine + ex.Message); } } } }
/// <summary> /// Illustrate of more work... /// </summary> public void OtherWork2() { // Login to Ge.tt var user = new Gett.Sharing.GettUser(); user.Login("myapikey", "mymail@local", "mypassword"); // Create new share Gett.Sharing.GettShare share1 = user.Shares.CreateShare(DateTime.Now.ToString("s")); Gett.Sharing.GettFile file1 = share1.CreateFile("MyDataFile." + DateTime.Now.ToString("s") + ".txt"); // Upload own string as a file to Ge.tt const string myDataString = "Hello from Gett.NET library"; file1.UploadData(System.Text.Encoding.UTF8.GetBytes(myDataString)); // Download file as a string or ... byte[] content = file1.DownloadData(); string contentString = System.Text.Encoding.UTF8.GetString(content); if (myDataString == contentString) { MessageBox.Show(@"It is a match!"); } // Download content to a local file file1.DownloadFile(@"C:\TEMP\MyFileFromGett.txt"); // Delete file or ... file1.Destroy(); // Delete share and all files share1.Destroy(); }
public UploadDownloadProgress(bool upload, string fileName, Gett.Sharing.GettFile file) { _upload = upload; _fileName = fileName; _file = file; InitializeComponent(); }
public UploadDownloadProgress(bool upload, string fileName, Gett.Sharing.GettFile file) { _upload = upload; _fileName = fileName; _file = file; InitializeComponent(); }
/// <summary> /// Illustrate of work with the async/await i .NET 4.5 /// </summary> public async void OtherWorkAsync() { try { // Login to Ge.tt var user = new Gett.Sharing.GettUser(); await user.LoginAsync("myapikey", "mymail@local", "mypassword"); // Create new share Gett.Sharing.GettShare share1 = await user.Shares.CreateShareAsync(DateTime.Now.ToString("s")); Gett.Sharing.GettFile file1 = await share1.CreateFileAsync("MyDataFile." + DateTime.Now.ToString("s") + ".txt"); // Upload own string as a file to Ge.tt const string myDataString = "Hello from Gett.NET library with async/await"; await file1.UploadDataAsync(System.Text.Encoding.UTF8.GetBytes(myDataString)); // Download file as a string or ... byte[] content = await file1.DownloadDataAsync(); string contentString = System.Text.Encoding.UTF8.GetString(content); if (myDataString == contentString) { MessageBox.Show(@"It is a match!"); } // Download content to a local file await file1.DownloadFileAsync(@"C:\Workspace\MyFileFromGett.txt"); // Delete file or ... await file1.DestroyAsync(); // Delete share and all files await share1.DestroyAsync(); } catch (Exception ex) { MessageBox.Show(@"Exception" + ex); } }