|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
File synchro question...I am coding an application which consists of a webservice and a client application. I am comparing the files on the server and the one on the client with hash-code and dates, so I can synchronize. That is working correctly. My problem is, if I am deleting one file on the client, then synchronize, how does the server know that it has been deleted? Actually it is then copying it back again to the client... The problem occurs specially if I am using 2-3 clients to synchronize. If I then delete the file on one client, but then make some changes to the file on another client, then I am synchronizing client 1 and then client 2, it should keep the new client 2-version! So I should be able somehow to know when the file has been deleted... Or is there another approach? Thanks Sven It isn't real clear from your post if the server is writing directly to the
client or not or if the client is getting the file from the server and then saving it. Without more information it is hard to say exactly but, assuming it fits for your circumstance, the FileSystemWatcher class will allow you to automatically detect when a file is changed, added, or deleted. HTH Dale -- Show quoteDale Preston MCAD C# MCSE, MCDBA "Sven Rutten" wrote: > Hello > > I am coding an application which consists of a webservice and a client > application. > I am comparing the files on the server and the one on the client with > hash-code and dates, so I can synchronize. That is working correctly. > > My problem is, if I am deleting one file on the client, then synchronize, > how does the server know that it has been deleted? Actually it is then > copying it back again to the client... > > The problem occurs specially if I am using 2-3 clients to synchronize. If I > then delete the file on one client, but then make some changes to the file > on another client, then I am synchronizing client 1 and then client 2, it > should keep the new client 2-version! > > So I should be able somehow to know when the file has been deleted... > > Or is there another approach? > > Thanks > > Sven > > > You will need to have the app running all the time, probably as a service,
and use the FileSystemWatch to record all the changes. Then you can send all lists to the server and let is figure out what to do to sync Ciaran O'Donnell Show quote "Sven Rutten" wrote: > Hello > > I am coding an application which consists of a webservice and a client > application. > I am comparing the files on the server and the one on the client with > hash-code and dates, so I can synchronize. That is working correctly. > > My problem is, if I am deleting one file on the client, then synchronize, > how does the server know that it has been deleted? Actually it is then > copying it back again to the client... > > The problem occurs specially if I am using 2-3 clients to synchronize. If I > then delete the file on one client, but then make some changes to the file > on another client, then I am synchronizing client 1 and then client 2, it > should keep the new client 2-version! > > So I should be able somehow to know when the file has been deleted... > > Or is there another approach? > > Thanks > > Sven > > > Or you can take a mixed approach. Use the FileSystemWatcher to catch
immediate changes and use a timer to trigger incremental scans of the watched folders to check for changes made while the app is not running. The latter is similar to what Windows Media Player does. Of course if real time knowledge of changes is required and there are serious financial or business implications then neither the FileSystemWatcher or a triggered event may be adequate. In those cases, it might be better to manually check the file system before making whatever decisions in the workflow are based on the file being changed or deleted or not. -- Show quoteDale Preston MCAD C# MCSE, MCDBA "Ciaran O''Donnell" wrote: > You will need to have the app running all the time, probably as a service, > and use the FileSystemWatch to record all the changes. Then you can send all > lists to the server and let is figure out what to do to sync > > Ciaran O'Donnell > > "Sven Rutten" wrote: > > > Hello > > > > I am coding an application which consists of a webservice and a client > > application. > > I am comparing the files on the server and the one on the client with > > hash-code and dates, so I can synchronize. That is working correctly. > > > > My problem is, if I am deleting one file on the client, then synchronize, > > how does the server know that it has been deleted? Actually it is then > > copying it back again to the client... > > > > The problem occurs specially if I am using 2-3 clients to synchronize. If I > > then delete the file on one client, but then make some changes to the file > > on another client, then I am synchronizing client 1 and then client 2, it > > should keep the new client 2-version! > > > > So I should be able somehow to know when the file has been deleted... > > > > Or is there another approach? > > > > Thanks > > > > Sven > > > > > > |
|||||||||||||||||||||||