Link to home
Start Free TrialLog in
Avatar of dsk1234
dsk1234

asked on

Windows service in .net

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
ASKER CERTIFIED SOLUTION
Avatar of kaminda
kaminda
Flag of Sri Lanka image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dsk1234
dsk1234

ASKER

       
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";
            copydirectory(src,dest);


 public static void copydirectory(string s,string d)
        {

            string [] files;

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

            if(!System.IO.Directory.Exists(d))
                System.IO.Directory.CreateDirectory(d);

            files=System.IO.Directory.GetFileSystemEntries(s);

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

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


                else
                     System.IO.File.Copy(element,d+System.IO.Path.GetFileName(element),true);
 
            }