Click here to Skip to main content
15,922,166 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when i use picturebox at string file and debug code it give me error of image path. when i use image path where my image is located at drive then it upload it to dropbox folder ...so guys help me.

What I have tried:

<pre>
        static string token = "<removed>";

        async Task Upload()
        {
            

            using (var dbx = new DropboxClient(token))

            {
                //C: \Users\home\Downloads\abba.JPG
               
                string file = @pictureBox1.Image.ToString();
                string folder = "";
                string filename = "Ali-20-june-2020";
                string url = pictureBox1.Image.ToString();
                using (var mem = new MemoryStream(File.ReadAllBytes(file)))

                {
                    var updated = dbx.Files.UploadAsync(folder + "/" + filename, WriteMode.Overwrite.Instance, body: mem);
                    updated.Wait();
                    var tx = dbx.Sharing.CreateSharedLinkWithSettingsAsync(folder + "/" + filename);
                    tx.Wait();
                    url = tx.Result.Url;

                }

                //Console.Write(url)
            }


        }



click button code
private void button1_Click(object sender, EventArgs e)
        {
            //var task = Task.Run((Func<Task>)this.Upload);
            //task.Wait();


            var awt = Task.Run((Func<Task>)this.Upload);
            awt.Wait();
        }


when i debug code then this error occur

FileNotFoundException: Could not find file 'E:\visual studio projects\Windows form Application tutorials\Dropbox Api Demo\Dropbox Api Demo\bin\Debug\System.Drawing.Bitmap'.
Posted
Updated 21-Jun-20 1:52am
v3
Comments
Member 14852747 21-Jun-20 5:01am    
Anyone Answer plz....
Richard MacCutchan 21-Jun-20 5:54am    
People answer questions in their own time and at their own speed. And since today is the weekend many people will be taking a rest. Please be patient.
[no name] 21-Jun-20 6:52am    
string file = @pictureBox1.Image.ToString(); is far away of being the file name...
Richard MacCutchan 21-Jun-20 7:28am    
Well spotted; you could probably add a few more words and post as a solution.
[no name] 21-Jun-20 7:44am    
Thank you, but my English is too bad. I don't find good words how to describe that "code cemetery" :)

1 solution

As mentioned by 0x01AA* above the following line will not give the name of he file:
C#
string file = @pictureBox1.Image.ToString();

This is clear from the error message which shows the filename as
E:\visual studio projects\Windows form Application tutorials\Dropbox Api Demo\Dropbox Api Demo\bin\Debug\System.Drawing.Bitmap

It is reasonable to assume that you have not called your file System.Drawing.Bitmap.

So, you just need to change your code to use the correct name for your file.

*who deserves the credit for this answer.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900