Make a folder like Dropbox that connects with a remote location
How can I make a folder that does things. Surely dropbox knows when a file is put in the folder, and that file is synced. How can I make a folder that does the same, and that the files I put 开发者_JAVA技巧in it go to my ftp?
I'm trying to do this on a Mac (surely, Dropbox works fine on a Mac).
I believe what you are looking for is a way to monitor when files are changed. Then, you can simply upload the changed file via FTP like you mentioned. If this is the case, the answer is to tie into the Windows Folder and File events. Here is a good article on how to do so:
http://www.codeproject.com/KB/files/MonitorFolderActivity.aspx
The code needed to FTP a file can be found here:
http://msdn.microsoft.com/en-us/library/ms229715.aspx
All of this is assuming you are going to be using C#. If you are going to use a different language, you will need to perform the same basic actions in the same basic manner but the syntax will be different.
To get started, this is all you need. You watch the folder for changes to any of the files. When you see a change, you upload the changed file via FTP (if that is your desired method of web transport) to the remote location. Of course, you would need to do the opposite for other clients. They would need to subscribe to events on your server that told them to download the latest versions of the changed files. Finally, you would need to apply your own business logic for things like how often you want the uploads to happen, if you want logging enabled for the changes, if you are going to do file versioning, etc.
One solution(windows only + .NET) would be to run a client with and monitor a folder with FileSystemWatcher and when the change event fires, do appropriate action required to sync with FTP.
精彩评论