unsal osma

unsal osma

  • NA
  • 44
  • 1.5k

upload all the files in the folder one by one

Nov 14 2018 1:21 PM
Hello
 
Google drive with c#
 
upload all the files in the folder one by one
 
my code this;
 
private void button1_Click(object sender, EventArgs e)
{
textBox10.Clear();
try
{
UserCredential credential;
credential = GetCredentials();
var service = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName ="TDBACKUP",
});
string folderid;
var fileMetadatas = new Google.Apis.Drive.v3.Data.File()
{
Name = txtFolderNameUpload.Text,
MimeType = "application/vnd.google-apps.folder"
};
var requests = service.Files.Create(fileMetadatas);
requests.Fields = "id";
folderid = "";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
label7.Text = "Son Yüklenen Dosya Adi : " + txtFolderNameUpload.Text + "\r\n\r\n";
foreach (string filename in openFileDialog1.FileNames)
{
Thread thread = new Thread(() =>
{
UploadFolder(filename, service, folderid);
label7.Text += "Yedekleme Basarili." + "\r\n";
});
thread.IsBackground = true;
thread.Start();
}
MessageBox.Show("islem tamam");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + " " + ex.InnerException);
}
}

Answers (2)