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