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)");

                    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??


Sorry for troubling you all..

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.