0

Hi..

Following is my code:-

   public static void Sync(string sourcePath, string destinationPath)
        {
            bool dirExisted = DirExists(destinationPath);

            //get the source files
            string[] srcFiles = Directory.GetFiles(sourcePath);

            foreach (string sourceFile in srcFiles)
            {
                FileInfo sourceInfo = new FileInfo(sourceFile);
                string destFile = Path.Combine(destinationPath, sourceInfo.Name);

                if (!dirExisted && File.Exists(destFile))
                {
                    FileInfo destInfo = new FileInfo(destFile);
                    if (sourceInfo.LastWriteTime > destInfo.LastWriteTime)
                    {
                        //file is newer, so copy it
                        File.Copy(sourceFile, Path.Combine(destinationPath, sourceInfo.Name), true);

                       MessageBox.Show(sourceFile + "copied(newer version)");



                        //Console.WriteLine(sourceFile + " copied (newer version)");
                    }
                }

                else
                {
                    File.Copy(sourceFile, Path.Combine(destinationPath, sourceInfo.Name));
                   // MessageBox.Show(sourceFile + "copied");



                    //Console.WriteLine(sourceFile + " copied");
                }
            }

            DeleteOldDestinationFiles(srcFiles, destinationPath);

            //now process the directories if exist
            string[] dirs = Directory.GetDirectories(sourcePath);

            foreach (string dir in dirs)
            {
                DirectoryInfo dirInfo = new DirectoryInfo(dir);

                //recursive do the directories
                Sync(dir, Path.Combine(destinationPath, dirInfo.Name));
            }
        }

here instead of MessageBoxes i want to use ToolStripStatus Label..

can anyone help me with this??

Thanks..

Edited by Dani: Formatting fixed

1
Contributor
1
Reply
2
Views
5 Years
Discussion Span
Last Post by bhagyap
0

Sorry for troubling you all..

I just need to remove static keyword and it'll work fine..

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.