Reputation: 323
I am using DropNet. I have problem with upload file into DropBox. I am sure the connection with dropbox in fine. when I changed the method of upload to create file and delete file method that works fine. I really can not see any problem that why is not uploading? I use exactly same API as DropNet.
protected void Btn_upload_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
if (Session["DropNetUserLogin"] != null)
{
try
{
_client.UseSandbox = true;
_client.UploadFile("/", FileUpload1.FileName, FileUpload1.FileBytes);
}
catch (Exception ex)
{
litOutput.Text = "Error in upload user login in session " + ex.Message;
}
}
else
{
litOutput.Text = "Session expired...";
}
}
else
{
litOutput.Text = "You did not specify a file to upload.";
}
}
}
Upvotes: 0
Views: 1569
Reputation: 1
Here is code which worked for me, hoping that this may help you:
private void button1_Click(object sender, RoutedEventArgs e)
{
var dlg = new OpenFileDialog();
dlg.Filter = "Text documents (.txt)|*.txt";
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
string filename = dlg.FileName;
FileNameTextBox.Text = filename;
}
var x = @"/" + Path.GetFileName(FileNameTextBox.Text);
_client.UploadFile("/", Path.GetFileName(FileNameTextBox.Text), File.ReadAllBytes(@"" + FileNameTextBox.Text));
}
Upvotes: 0