Пример #1
0
        // Download a file
        private void DownloadFileTransfer(FileTransfer file)
        {
            string      folder;
            ctlTransfer TransferFile;

            TransferFile = new ctlTransfer();
            file.Blob.FetchAttributes();
            folder = txtLocalDownloadPath_FileTransfer.Text;
            folder = System.IO.Path.Combine(folder, file.Container);
            TransferFile.LocalFile          = System.IO.Path.Combine(folder, System.IO.Path.GetFileName(file.Blob.Uri.AbsolutePath));
            TransferFile.FileLength         = file.Blob.Attributes.Properties.Length;
            TransferFile.TransferCompleted += new EventHandler <AsyncCompletedEventArgs>(FileTransfer_DownloadCompleted);
            TransferFile.Tag  = file.lvi;
            TransferFile.Blob = file.Blob;
            flowLayoutPanel1.Controls.Add(TransferFile);
            flowLayoutPanel1.ScrollControlIntoView(TransferFile);
            TransferFile.Download();
            ActiveTransfers.Add(TransferFile);

            file.lvi.ImageKey = "Downloading";
        }
Пример #2
0
        // Upload a file
        private void UploadFileTransfer(string File)
        {
            if (txtUploadContainer.Text == "")
            {
                MessageBox.Show("Enter a container (usually your alias)");
                return;
            }

            txtUploadContainer.Text = txtUploadContainer.Text.Replace("\\", "/");

            CloudBlob blob = ContainerFileTransfer.GetBlobReference(txtUploadContainer.Text + "/" + System.IO.Path.GetFileName(File));

            ctlTransfer UploadFile = new ctlTransfer();

            UploadFile.Blob               = blob;
            UploadFile.URL                = blob.Uri.AbsoluteUri;
            UploadFile.LocalFile          = File;
            UploadFile.FileLength         = new System.IO.FileInfo(File).Length;
            UploadFile.TransferCompleted += new EventHandler <AsyncCompletedEventArgs>(UploadFile_UploadCompleted);
            flowLayoutPanel1.Controls.Add(UploadFile);
            flowLayoutPanel1.ScrollControlIntoView(UploadFile);
            UploadFile.Upload();
            ActiveTransfers.Add(UploadFile);
        }