0

我正在使用 DropNet。我在将文件上传到 DropBox 时遇到问题。我确信与保管箱的连接很好。当我更改上传方法以创建文件和删除文件方法时效果很好。我真的看不出有什么问题,为什么不上传?我使用与 DropNet 完全相同的 API。

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.";
        }
    }
}
4

1 回答 1

0

这是对我有用的代码,希望对您有所帮助:

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));
}
于 2014-04-22T15:35:54.537 回答