<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to get Progress Status while uploading/ downloading a file ( in .Net ) ? in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-get-Progress-Status-while-uploading-downloading-a-file-in/m-p/170685#M17203</link>
    <description>&lt;P&gt;The .NET SDK doesn't offer native progress listeners, but I'll be sure to pass this along as a feature request. You can however track download progress using GetContentAsStreamAsync. E.g., you can do something like:&lt;/P&gt;
&lt;PRE&gt;var response = await client.Files.DownloadAsync(path);&lt;BR /&gt;ulong fileSize = response.Response.Size;&lt;BR /&gt;const int bufferSize = 1024 * 1024;&lt;BR /&gt;&lt;BR /&gt;var buffer = new byte[bufferSize];&lt;BR /&gt;&lt;BR /&gt;using (var stream = await response.GetContentAsStreamAsync())&lt;BR /&gt;{&lt;BR /&gt; using (var file = new FileStream("Test", FileMode.OpenOrCreate))&lt;BR /&gt; {&lt;BR /&gt; var length = stream.Read(buffer, 0, bufferSize);&lt;BR /&gt;&lt;BR /&gt; while (length &amp;gt; 0)&lt;BR /&gt; {&lt;BR /&gt; file.Write(buffer, 0, length);&lt;BR /&gt; var percentage = 100 * (ulong)file.Length / fileSize;&lt;BR /&gt; // Update progress bar with the percentage.&lt;BR /&gt; // progressBar.Value = (int)percentage&lt;BR /&gt; Console.WriteLine(percentage);&lt;BR /&gt;&lt;BR /&gt; length = stream.Read(buffer, 0, bufferSize);&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt;}&lt;/PRE&gt;
&lt;P&gt;You can do something similar for uploads using &lt;A href="https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Files_Routes_FilesRoutes_UploadSessionStartAsync_1.htm" target="_blank" rel="nofollow noreferrer"&gt;upload sessions&lt;/A&gt; (i.e., update your progress between chunks).&lt;/P&gt;</description>
    <pubDate>Thu, 16 Jun 2016 23:55:46 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2016-06-16T23:55:46Z</dc:date>
    <item>
      <title>How to get Progress Status while uploading/ downloading a file ( in .Net ) ?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-get-Progress-Status-while-uploading-downloading-a-file-in/m-p/170684#M17202</link>
      <description>&lt;P&gt;I am using&amp;nbsp;DropboxClient.Files.UploadAsync method for uploading file and&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DropboxClient.Files.DownloadAsync for downloading.&lt;/P&gt;
&lt;P&gt;Uploading and Downloading works perfectly but can't get the progress status.&lt;/P&gt;
&lt;P&gt;A example in C# will be very helpful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:12:26 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-get-Progress-Status-while-uploading-downloading-a-file-in/m-p/170684#M17202</guid>
      <dc:creator>RAJIB N.</dc:creator>
      <dc:date>2019-05-29T09:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Progress Status while uploading/ downloading a file ( in .Net ) ?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-get-Progress-Status-while-uploading-downloading-a-file-in/m-p/170685#M17203</link>
      <description>&lt;P&gt;The .NET SDK doesn't offer native progress listeners, but I'll be sure to pass this along as a feature request. You can however track download progress using GetContentAsStreamAsync. E.g., you can do something like:&lt;/P&gt;
&lt;PRE&gt;var response = await client.Files.DownloadAsync(path);&lt;BR /&gt;ulong fileSize = response.Response.Size;&lt;BR /&gt;const int bufferSize = 1024 * 1024;&lt;BR /&gt;&lt;BR /&gt;var buffer = new byte[bufferSize];&lt;BR /&gt;&lt;BR /&gt;using (var stream = await response.GetContentAsStreamAsync())&lt;BR /&gt;{&lt;BR /&gt; using (var file = new FileStream("Test", FileMode.OpenOrCreate))&lt;BR /&gt; {&lt;BR /&gt; var length = stream.Read(buffer, 0, bufferSize);&lt;BR /&gt;&lt;BR /&gt; while (length &amp;gt; 0)&lt;BR /&gt; {&lt;BR /&gt; file.Write(buffer, 0, length);&lt;BR /&gt; var percentage = 100 * (ulong)file.Length / fileSize;&lt;BR /&gt; // Update progress bar with the percentage.&lt;BR /&gt; // progressBar.Value = (int)percentage&lt;BR /&gt; Console.WriteLine(percentage);&lt;BR /&gt;&lt;BR /&gt; length = stream.Read(buffer, 0, bufferSize);&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt;}&lt;/PRE&gt;
&lt;P&gt;You can do something similar for uploads using &lt;A href="https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Files_Routes_FilesRoutes_UploadSessionStartAsync_1.htm" target="_blank" rel="nofollow noreferrer"&gt;upload sessions&lt;/A&gt; (i.e., update your progress between chunks).&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 23:55:46 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-get-Progress-Status-while-uploading-downloading-a-file-in/m-p/170685#M17203</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2016-06-16T23:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Progress Status while uploading/ downloading a file ( in .Net ) ?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-get-Progress-Status-while-uploading-downloading-a-file-in/m-p/170686#M17204</link>
      <description>&lt;P&gt;Thanks for the reply.&lt;/P&gt;
&lt;P&gt;Anyway, could you send me the C# code for upload as I can not get any complete solutions in the net. Also I am not sure how can I upload files &amp;gt; 150 MB&amp;nbsp;to Dropbox.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2016 15:34:10 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-get-Progress-Status-while-uploading-downloading-a-file-in/m-p/170686#M17204</guid>
      <dc:creator>RAJIB N.</dc:creator>
      <dc:date>2016-06-17T15:34:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Progress Status while uploading/ downloading a file ( in .Net ) ?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-get-Progress-Status-while-uploading-downloading-a-file-in/m-p/170687#M17205</link>
      <description>&lt;P&gt;Here's a sample of uploading using upload sessions:&lt;/P&gt;
&lt;PRE&gt;private async Task ChunkUpload(String path, FileStream stream, int chunkSize)&lt;BR /&gt;{&lt;BR /&gt; int numChunks = (int)Math.Ceiling((double)stream.Length / chunkSize);&lt;BR /&gt; byte[] buffer = new byte[chunkSize];&lt;BR /&gt; string sessionId = null;&lt;BR /&gt; for (var idx = 0; idx &amp;lt; numChunks; idx++)&lt;BR /&gt; {&lt;BR /&gt; var byteRead = stream.Read(buffer, 0, chunkSize);&lt;BR /&gt;&lt;BR /&gt; using (var memSream = new MemoryStream(buffer, 0, byteRead))&lt;BR /&gt; {&lt;BR /&gt; if (idx == 0)&lt;BR /&gt; {&lt;BR /&gt; var result = await this.client.Files.UploadSessionStartAsync(memSream);&lt;BR /&gt; sessionId = result.SessionId;&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; var cursor = new UploadSessionCursor(sessionId, (ulong)(chunkSize * idx));&lt;BR /&gt;&lt;BR /&gt; if (idx == numChunks - 1)&lt;BR /&gt; {&lt;BR /&gt; await this.client.Files.UploadSessionFinishAsync(cursor, new CommitInfo(path), memSream);&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; await this.client.Files.UploadSessionAppendAsync(cursor, memSream);&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt;}&lt;/PRE&gt;</description>
      <pubDate>Sat, 18 Jun 2016 00:55:22 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-get-Progress-Status-while-uploading-downloading-a-file-in/m-p/170687#M17205</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2016-06-18T00:55:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Progress Status while uploading/ downloading a file ( in .Net ) ?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-get-Progress-Status-while-uploading-downloading-a-file-in/m-p/170688#M17206</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have tried with downloading and uploading functions supplied by you, it gives the progress data alright, but I can not set that data to progress bar. I have worked with couple of hours but can not place that process status in the progress bar or any other way. I have attached codes of Upload&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;private async Task ChunkUpload()&lt;BR /&gt; {&lt;/P&gt;
&lt;PRE&gt;string path = UploadFolder + "/" + UploadFile;&lt;BR /&gt; FileStream stream = UploadFileStream;&lt;BR /&gt; int chunkSize = 128 * 1024;&lt;BR /&gt; &lt;BR /&gt; DropboxClient dbx = new DropboxClient(SystemVariables.WebAcccessToken);&lt;BR /&gt; int numChunks = (int)Math.Ceiling((double)stream.Length / chunkSize);&lt;BR /&gt; byte[] buffer = new byte[chunkSize];&lt;BR /&gt; string sessionId = null;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt; for (var idx = 0; idx &amp;lt; numChunks; idx++)&lt;BR /&gt; {&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt; var byteRead = stream.Read(buffer, 0, chunkSize);&lt;BR /&gt;&lt;BR /&gt; using (var memSream = new MemoryStream(buffer, 0, byteRead))&lt;BR /&gt; {&lt;BR /&gt; if (idx == 0)&lt;BR /&gt; {&lt;BR /&gt; var result = await dbx.Files.UploadSessionStartAsync(false, memSream);&lt;BR /&gt; sessionId = result.SessionId;&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; var cursor = new UploadSessionCursor(sessionId, (ulong)(chunkSize * idx));&lt;BR /&gt; var percentage = 100 * ((chunkSize * idx) / (double)stream.Length);&lt;BR /&gt; pValue = (int)Math.Ceiling((decimal)percentage);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; // Approach 1&lt;BR /&gt;&lt;BR /&gt; &lt;STRONG&gt;var progressIndicator = new Progress&amp;lt;int&amp;gt;(ReportProgress);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; int uploads = await UploadProgress(progressIndicator);&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;PRE&gt;// Approach 2&lt;/PRE&gt;
&lt;PRE&gt;&lt;BR /&gt;&lt;STRONG&gt; /*&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; Thread t = new Thread(new ThreadStart(this.DoProcess));&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt; t.Start();&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt; while (t.IsAlive) // while thread is running&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; {&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt; Application.DoEvents(); // Allow UI to refresh if needed&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt; Thread.Sleep(10000); // sleep a while to avoid processor load&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; t.Abort();&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; }*/&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt; if (idx == numChunks - 1)&lt;BR /&gt; {&lt;BR /&gt; await dbx.Files.UploadSessionFinishAsync(cursor, new CommitInfo(path), memSream);&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; await dbx.Files.UploadSessionAppendV2Async(cursor,false, memSream);&lt;BR /&gt; &lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; public delegate void UpdateProgressBarDelegate(int progress);&lt;BR /&gt; public UpdateProgressBarDelegate UpdateProgressBar;&lt;BR /&gt;&lt;BR /&gt; private void UpdateProgressBarMethod(int progress)&lt;BR /&gt; {&lt;BR /&gt; IAsyncResult result = this.progressBar1.BeginInvoke(&lt;BR /&gt; (MethodInvoker)delegate()&lt;BR /&gt; {&lt;BR /&gt; progressBar1.Value = progress;&lt;BR /&gt; Text = progress.ToString();&lt;BR /&gt; //txtLogDetails.Text = message; &lt;BR /&gt;&lt;BR /&gt; });&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;private void DoProcess()&lt;BR /&gt; {&lt;BR /&gt; UpdateProgressBarMethod(pValue);&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;void ReportProgress(int value)&lt;BR /&gt; {&lt;BR /&gt; progressBar1.Value = value;&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; async Task&amp;lt;int&amp;gt; UploadProgress(IProgress&amp;lt;int&amp;gt; progress)&lt;BR /&gt; {&lt;BR /&gt; int processCount = await Task.Run&amp;lt;int&amp;gt;(() =&amp;gt;&lt;BR /&gt; {&lt;BR /&gt; if (progress != null)&lt;BR /&gt; {&lt;BR /&gt; progress.Report(pValue);&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; return pValue;&lt;BR /&gt; });&lt;BR /&gt; return processCount;&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;You can see the 2 approaches that I have tried to update progress bar value,&lt;BR /&gt;but can not see the update in progress bar.&lt;BR /&gt;&lt;BR /&gt;It will be great if you provide the detail code for display updates in progress bar from the scratch.&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Jun 2016 21:32:47 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-get-Progress-Status-while-uploading-downloading-a-file-in/m-p/170688#M17206</guid>
      <dc:creator>RAJIB N.</dc:creator>
      <dc:date>2016-06-21T21:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Progress Status while uploading/ downloading a file ( in .Net ) ?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-get-Progress-Status-while-uploading-downloading-a-file-in/m-p/170689#M17207</link>
      <description>&lt;P&gt;It sounds like the&amp;nbsp;Dropbox part of this is working, and you're having trouble with the UI side of this. That's outside the scope of&amp;nbsp;Dropbox API support, so I'm afraid I can't be of any help with that.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2016 00:18:56 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-get-Progress-Status-while-uploading-downloading-a-file-in/m-p/170689#M17207</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2016-06-22T00:18:56Z</dc:date>
    </item>
  </channel>
</rss>

