Windows service in .net

dsk1234 used Ask the Experts™
I need some direction to write the code for window service in .net.

My requirement is to move all the files from x folder to y folder for every 2 hours
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
In this tutorial you it is describing how to write a Windows service

This describes how to move files

To do it in a time interval use a timer control in side the service set the interval as you want.

This is how you can do it


Hi ,

I am able to copy files and subdirectories from one folder to other ,but I need to move files and subdirectories to other folder

Here is the code for copying files and subdirectories to other folder which is working fine.

Can any one help me to just modify below code that will move files and subfolders to other folder

 and also while moving check if any file is being used by any another process we need to skip that file

and move other files   ?

button cick event

             string src="D:\\SRC";
            string dest="D:\\DEST";

 public static void copydirectory(string s,string d)

            string [] files;

            if(d[d.Length -1]!=System.IO.Path.DirectorySeparatorChar)



            foreach (string element in files )
                if (System.IO.Directory.Exists(element))

                    copydirectory(element, d + System.IO.Path.GetFileName(element));


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial