Click here to Skip to main content
15,886,823 members
Home / Discussions / C#
   

C#

 
GeneralRe: Named pipes: C# server, C++ client Pin
Crazy Joe Devola16-Feb-16 12:03
Crazy Joe Devola16-Feb-16 12:03 
GeneralRe: Named pipes: C# server, C++ client Pin
Richard Andrew x6416-Feb-16 12:27
professionalRichard Andrew x6416-Feb-16 12:27 
GeneralRe: Named pipes: C# server, C++ client Pin
Crazy Joe Devola16-Feb-16 12:46
Crazy Joe Devola16-Feb-16 12:46 
AnswerRe: Named pipes: C# server, C++ client Pin
Crazy Joe Devola16-Feb-16 13:12
Crazy Joe Devola16-Feb-16 13:12 
GeneralRe: Named pipes: C# server, C++ client Pin
Richard Andrew x6416-Feb-16 13:15
professionalRichard Andrew x6416-Feb-16 13:15 
QuestionHow to read and print *.plt file by C# Pin
tienich15-Feb-16 22:01
tienich15-Feb-16 22:01 
AnswerRe: How to read and print *.plt file by C# Pin
Pete O'Hanlon15-Feb-16 22:32
mvePete O'Hanlon15-Feb-16 22:32 
QuestionCopy File From Server With Progress And Completion Pin
Kevin Marois15-Feb-16 18:42
professionalKevin Marois15-Feb-16 18:42 
Overview
I'm working on this class to asynchronously copy files to/from the server. I want to run it in tasks so that I can copy many files at one time without blocking.

I've pieced this class together from Google results and trial and error. It does two things for me:

1) Reports the progress of the copy

2) Reports when it's done.

The FileEx class I got from here[^].

Questions
1) How can I include the name of the file in the progress?

2) How can I include the name of the file when done?

Here's the class:
using System;
using System.Threading.Tasks;
using MyApp.FileTransfer;
using MyApp.Client.Classes;

namespace MyApp.Client.FileTransfer
{
    public class LANFileTransfer : IFileTransfer
    {
        #region Public Methods
        // Copy a file to/from the server
        public async void DownloadFile(string sourceFile, string destFile)
        {
            await Task.Run(async () => 
            {
                await TransferFile(sourceFile, destFile);
            }).ContinueWith((t) => FileTransferComplete(t));
        }
        #endregion

        #region Private Methods

        // Called when the file transfer has completed
        private void FileTransferComplete(Task task)
        {
        }

        // Report progress on the file
        private void FileTransferProgress(double percentage)
        {
        }

        // Copy the file
        private async Task TransferFile(string sourceFile, string destFile)
        {
            IProgress<double> progress = new Progress<double>(FileTransferProgress);
            await FileEx.CopyAsync(sourceFile, destFile, progress);
        }

        #endregion
    }
}

Thanks
If it's not broken, fix it until it is

AnswerRe: Copy File From Server With Progress And Completion Pin
Garth J Lancaster15-Feb-16 19:26
professionalGarth J Lancaster15-Feb-16 19:26 
AnswerRe: Copy File From Server With Progress And Completion Pin
Richard Deeming16-Feb-16 2:06
mveRichard Deeming16-Feb-16 2:06 
GeneralRe: Copy File From Server With Progress And Completion Pin
Kevin Marois16-Feb-16 3:38
professionalKevin Marois16-Feb-16 3:38 
AnswerRe: Copy File From Server With Progress And Completion Pin
Pete O'Hanlon16-Feb-16 2:10
mvePete O'Hanlon16-Feb-16 2:10 
GeneralRe: Copy File From Server With Progress And Completion Pin
Kevin Marois16-Feb-16 3:36
professionalKevin Marois16-Feb-16 3:36 
QuestionIcon on "Dekstop" Pin
Member 1224802815-Feb-16 12:01
Member 1224802815-Feb-16 12:01 
QuestionRe: Icon on "Dekstop" Pin
ZurdoDev15-Feb-16 13:55
professionalZurdoDev15-Feb-16 13:55 
AnswerRe: Icon on "Dekstop" Pin
Gerry Schmitz16-Feb-16 6:05
mveGerry Schmitz16-Feb-16 6:05 
Questionsingle submit button with multiple tabs Pin
Sandy Safwat15-Feb-16 7:19
Sandy Safwat15-Feb-16 7:19 
AnswerRe: single submit button with multiple tabs Pin
Richard Deeming15-Feb-16 8:09
mveRichard Deeming15-Feb-16 8:09 
GeneralRe: single submit button with multiple tabs Pin
Sandy Safwat15-Feb-16 9:19
Sandy Safwat15-Feb-16 9:19 
GeneralRe: single submit button with multiple tabs Pin
Richard Deeming15-Feb-16 9:32
mveRichard Deeming15-Feb-16 9:32 
GeneralRe: single submit button with multiple tabs Pin
Sandy Safwat15-Feb-16 10:27
Sandy Safwat15-Feb-16 10:27 
GeneralRe: single submit button with multiple tabs Pin
Richard Deeming15-Feb-16 10:48
mveRichard Deeming15-Feb-16 10:48 
GeneralRe: single submit button with multiple tabs Pin
Mycroft Holmes15-Feb-16 13:39
professionalMycroft Holmes15-Feb-16 13:39 
GeneralRe: single submit button with multiple tabs Pin
Sandy Safwat15-Feb-16 18:38
Sandy Safwat15-Feb-16 18:38 
QuestionGet the name of the machine I'm remoted from... Pin
dandy7215-Feb-16 5:40
dandy7215-Feb-16 5:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.