Click here to Skip to main content
15,896,153 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear Friends,

I need move text file from source to destination and when coping file to source i need message "Please wait, file copying after copied you move to destination" using windows service. please help me.

What I have tried:

DirectoryInfo dir = new DirectoryInfo(@"D:\Vivek");

            FileInfo[] files = dir.GetFiles();

            foreach (FileInfo file in files)
            {                
                if (file.Length > 0)
                {                   
                        // you can delete file here if you want (destination file)
                        if (File.Exists(@"D:\Vivek\Moved\" + file.Name))
                        {
                            File.Delete(@"D:\Vivek\Moved\" + file.Name);
                        }

                        // then copy the file here
                        file.MoveTo(@"D:\Vivek\Moved\" + file.Name);
                    
                }
            }
Posted
Updated 12-Mar-17 23:38pm
v3
Comments
Richard MacCutchan 11-Mar-17 4:05am    
FTP, HTTP, custom app?
Vivek.anand34 13-Mar-17 1:10am    
any link or some code..
Vivek.anand34 13-Mar-17 1:38am    
I want message file transfer while copying the file "please wait file is copying".
F-ES Sitecore 13-Mar-17 5:40am    
Windows services can't really interact with the desktop so you can't show messages to the user etc.

1 solution

Consider doing the copy on a worker thread, then you can still update the GUI.

See
Beginners Guide to Threading in .NET: Part 1 of n[^]
Using Worker Threads[^]
Threading in .NET and WinForms[^]
 
Share this answer
 

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