954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Using control in functions c#

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

bhagyap
Light Poster
38 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

Sorry for troubling you all..

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

bhagyap
Light Poster
38 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: