Check files on 2 servers

  • Thread starter Thread starter Stephen
  • Start date Start date
S

Stephen

Hi,

I want to create an executable that can check folders on 2 servers and
synchronize them if files dont match.
Can some one please point me to the right direction (sample code etc..)

Thanks in advance,
Stephen
 
Dunno if I should =P

well I may have some pieces to you.
this will work on simple network:

for(int i=0;i<ServerID.Length;i++)
{
if(ServerID != "")
{
if(Directory.Exists("\\\\" + dp + "\\" + pathToDp + "\\" +
ServerID ))
{
table = new DataTable("\\\\" + dp + "\\" + pathToDp + "\\" +
ServerID);
table.Columns.Add("File_Name",Type.GetType("System.String"));
getAllFilesAndFolders("\\\\" + dp + "\\" + pathToDp + "\\" +
ServerID , "\\\\" + dp + "\\" + pathToDp + "\\" + ServerID , ref
table);
ds.Tables.Add(table);
ServerID = "";
}
}

private void getAllFilesAndFolders(string path , string baseRoot,ref
DataTable table)
{
DataRow row;
foreach(string s in Directory.GetDirectories(path) )
getAllFilesAndFolders(s,baseRoot,ref table);

string[] files = Directory.GetFiles(path);
foreach(string pkgFile in files)
{
row = table.NewRow();
row["File_Name"] = pkgFile.Replace(baseRoot,"");
table.Rows.Add(row);
}
}

well its not a working piece, need some fixes in some declarations.
Well what it does:
You put a path in the ServerID and it create a table with all the files
that are in the server, then all you have to do is create another table
with the files from the other server and compare then. Easy now right?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top