B
BurakGunduz
Guest
Hi,
I want to send Excel file to Google Drive from C#. I found this code for this, but I couldn't find out how to indroduce "UploadFolder". The "UploadFolder" part is undefined. How can I define this? I would be very happy if someone who understands the issues.
Cod is here:
private void button13_Click(object sender, EventArgs e)
{
try
{
UserCredential credential;
using (var stream = new FileStream("credentials.json", FileMode.Open, FileAccess.Read))
{
string credPath = "token.json";
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
Console.WriteLine("Credential file saved to: " + credPath);
}
// Create Drive API service.
var service = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
});
string folderid;
var fileMetadatas = new Google.Apis.Drive.v3.Data.File()
{
Name = txtFolderNameUpload.Text,
// Name = textBox7.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 Adı : " + txtFolderNameUpload.Text + "\r\n\r\n";
foreach (string filename in openFileDialog1.FileNames)
{
Thread thread = new Thread(() =>
{
UploadFolder(filename, service, folderid); \\ "UPLOADFOLDER" THAT REQUİRES İDENTİFİCATİON
label7.Text += "Yedekleme Başarılı." + "\r\n";
});
thread.IsBackground = true;
thread.Start();
}
MessageBox.Show("işlem tamam");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + " " + ex.InnerException);
}
}
Continue reading...
I want to send Excel file to Google Drive from C#. I found this code for this, but I couldn't find out how to indroduce "UploadFolder". The "UploadFolder" part is undefined. How can I define this? I would be very happy if someone who understands the issues.
Cod is here:
private void button13_Click(object sender, EventArgs e)
{
try
{
UserCredential credential;
using (var stream = new FileStream("credentials.json", FileMode.Open, FileAccess.Read))
{
string credPath = "token.json";
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
Console.WriteLine("Credential file saved to: " + credPath);
}
// Create Drive API service.
var service = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
});
string folderid;
var fileMetadatas = new Google.Apis.Drive.v3.Data.File()
{
Name = txtFolderNameUpload.Text,
// Name = textBox7.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 Adı : " + txtFolderNameUpload.Text + "\r\n\r\n";
foreach (string filename in openFileDialog1.FileNames)
{
Thread thread = new Thread(() =>
{
UploadFolder(filename, service, folderid); \\ "UPLOADFOLDER" THAT REQUİRES İDENTİFİCATİON
label7.Text += "Yedekleme Başarılı." + "\r\n";
});
thread.IsBackground = true;
thread.Start();
}
MessageBox.Show("işlem tamam");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + " " + ex.InnerException);
}
}
Continue reading...