Check files on 2 servers

Discussion in 'ASP .Net' started by Stephen, Jan 9, 2006.

  1. Stephen

    Stephen Guest

    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
     
    Stephen, Jan 9, 2006
    #1
    1. Advertising

  2. 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?
     
    Henrique Mello, Jan 9, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Halvor Nyberg

    Making files on other Servers available

    Halvor Nyberg, Oct 16, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    328
    Halvor Nyberg
    Oct 16, 2003
  2. Chris Strobel

    Copy files between servers

    Chris Strobel, Jul 26, 2004, in forum: ASP .Net
    Replies:
    8
    Views:
    6,169
    William F. Robertson, Jr.
    Jul 26, 2004
  3. Petr PALAS
    Replies:
    1
    Views:
    323
    Paul Glavich [MVP ASP.NET]
    Mar 10, 2005
  4. Kent Lichty
    Replies:
    0
    Views:
    5,665
    Kent Lichty
    Nov 7, 2003
  5. Replies:
    3
    Views:
    1,470
    Rolf Magnus
    Jan 18, 2009
Loading...

Share This Page