Exemple #1
0
 void service_DownloadChunkCompleted(object sender, DownloadChunkCompletedEventArgs e)
 {
     try
     {
         Byte[] byteArrayFile = (Byte[])e.Result;
         if (isFirstCall)
         {
             MessageBox _oBox = MessageBox.Show("Download file in chunk", "Are you sure to download the file ?", MsgBoxButtons.YesNo, MsgBoxIcon.Error, OnDialogClosed);
         }
         isFirstCall = false;
         if (fileDialog != null)
         {
             WriteIntoFile(fileDialog, byteArrayFile);
             I64Offset = I64Offset + i32ChunkSize;
             if (I64Offset < fileSize)
             {
                 IsFileToAppend = true;
                 service.DownloadChunkAsync(docName, I64Offset, i32ChunkSize);
             }
             else
             {
                 I64Offset = 0;
                 fileStream.Close();
                 System.Windows.MessageBox.Show("File downloaded succesfully.");
             }
         }
         else
         {
             service.DownloadChunkAsync(docName, I64Offset, i32ChunkSize);
         }
     }
     catch (Exception ex)
     {
     }
 }
Exemple #2
0
 public void DownloadFile(string DocURL)
 {
     // first you should get the file size from the server side in bytes.
     fileSize = 825344;
     service  = new UploadClient();
     service.InnerChannel.OperationTimeout = new TimeSpan(0, 30, 0);
     docName     = DocURL;
     isFirstCall = true;
     service.DownloadChunkCompleted += service_DownloadChunkCompleted;
     service.DownloadChunkAsync(DocURL, I64Offset, i32ChunkSize);
 }