file copying on LAN

smerch

Member
Joined
Nov 8, 2005
Messages
10
Programming Experience
3-5
I need to develop an application that will run on a client machine & copy files from a specific folder on the server. But there are 2 small things:
1. All files within the folder & sub-folders need to be copied.
2. A check needs to be done to see the DateModified property of the files already on the client & only those files whose DateModified property is different from the server copy of the file should get copied (reducing network overhead).

I already have a basic DOS batch file which uses XCOPY currently doing this, but the problem is that it copies files from the server only if:

ServerCopy.DateModified > ClientCopy.DateModified

if ServerCopy.DateModified < ClientCopy.DateModified then it should still copy the file (but isn't happening with the present batch file).

I didn't know if can be done as a Console Appl or a Win Appl so I've posted it here. Please give any suggestions/ideas or perhaps some basic code to start working with.

Thanx in advance.
 
Is the directory/file structure going to be the same on the client as it is on the server?

I have this for you so far, it will find all of your directories.
VB.NET:
[SIZE=2][COLOR=#008000]'Create Directory Array
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]'PRE: All Directories, files and subdirectories have atleast pathdiscovery permission
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]'POST: arrstrHold is populated with all subdirectories
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] arrstrHold() [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] strHold [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] repeater [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2] = 0
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] dynamicCount [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2] = 0[/SIZE]
[SIZE=2] 
  arrstrHold = IO.Directory.GetDirectories(strServerPath)
  dynamicCount = arrstrHold.Length
[/SIZE][SIZE=2][COLOR=#0000ff]  Do[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]While[/COLOR][/SIZE][SIZE=2] repeater < dynamicCount
[/SIZE][SIZE=2][COLOR=#0000ff]    If[/COLOR][/SIZE][SIZE=2] IO.Directory.GetDirectories(arrstrHold(repeater)).Length > 0 [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]      ReDim[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Preserve[/COLOR][/SIZE][SIZE=2] arrstrHold(UBound(arrstrHold) + IO.Directory.GetDirectories(arrstrHold(repeater)).Length)
      IO.Directory.GetDirectories(arrstrHold(repeater)).CopyTo(arrstrHold, arrstrHold.IndexOf(arrstrHold, [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][SIZE=2]))
      dynamicCount += IO.Directory.GetDirectories(arrstrHold(repeater)).Length
[/SIZE][SIZE=2][COLOR=#0000ff]    End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2]    repeater += 1
[/SIZE][SIZE=2][COLOR=#0000ff]  Loop
[/COLOR][/SIZE]
strServerPath is the parent directory you want to search through.
 
thanx a lot, have gotten started. Have worked my way through all directories & all files within those directories. Have also found way to check DateModified. But I now need to actually work out the file copying part, any ideas?

Thanx a ton sevenhalo. & yes the directory structure will be exactly replicated on the client.


perhaps after I complete the program, I shall post the entire code for others to use.
 
Back
Top