使用systemfilewatcher和ftp [英] working with systemfilewatcher and ftp

查看:154
本文介绍了使用systemfilewatcher和ftp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的.我的应用程序正在查看我的桌面,图片,音乐和文档文件夹.我看过类似ftp的示例:

Alright. I have my application watching my desktop, pictures, music, and document folders. I have seen examples of ftp similar to this:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim request As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("ftp://ftp.drivehq.com/file.txt"), System.Net.FtpWebRequest)
        request.Credentials = New System.Net.NetworkCredential("user", "password")
        request.Method = System.Net.WebRequestMethods.Ftp.UploadFile

        Dim file() As Byte = System.IO.File.ReadAllBytes("c:\file.txt")

        Dim strz As System.IO.Stream = request.GetRequestStream()
        strz.Write(file, 0, file.Length)
        strz.Close()
        strz.Dispose()
    End Sub

.这是处理程序:

AddHandler表文件夹.重命名为AddressOf logrename

我需要在sub logrename()中放入什么才能使其自动将重命名的文件上传到我的服务器上

so for instance. this is the handler:

AddHandler watchfolder.Renamed, AddressOf logrename

What would I need to put into the sub logrename() in order for it to automatically upload the renamed file onto my server

推荐答案

文件系统,FTP不支持通知.

要在运行FTP服务器的某些主机上实现所需的功能,您需要开发特殊的通知服务.此服务应在发布者-订阅者模型上起作用( http://en.wikipedia.org/wiki/Publish-subscribe [ ^ ]),通过以下方式接受事件通知的订阅网络,并根据用户身份验证在FTP覆盖的文件系统的某些部分发生更改时提供网络通知.

请参阅我过去的回答以了解此类架构的草图:
来自同一端口号的多个客户端 [ http://msdn.microsoft.com/en-us/library/system.io. filesystemwatcher.aspx [ ^ ].

对于Windows系统,适当的服务形式是Windows服务.请参阅:
http://en.wikipedia.org/wiki/Windows_service [ http://msdn.microsoft.com/en-us/library/d56de412%28v = vs.100%29.aspx [ ^ ].

—SA
Unlike file systems, FTP does not support notifications.

To implement the feature you want on some host running an FTP server, you would need to develop a special notification service. This service should work on the publisher-subscriber model (http://en.wikipedia.org/wiki/Publish-subscribe[^]), accept subscriptions for event notifications by network and provide network notifications if something changes in part of the file system covered by FTP, depending on user authentication.

Please see for the sketch of such architecture in my past answer:
Multple clients from same port Number[^].

Internally, if the service''s host runs Windows, you can use the class System.IO.FileSystemWatcher, please see:
http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx[^].

For Windows systems, the adequate form of the service is a Windows Service. Please see:
http://en.wikipedia.org/wiki/Windows_service[^],
http://msdn.microsoft.com/en-us/library/d56de412%28v=vs.100%29.aspx[^].

—SA


该应用程序将是.net桌面应用程序,可以将更改的文件上传到ftp服务器上.该服务器运行Linux.与dreamhost.com在一起
我当时计划使用system.io.filesystemwatcher,但我的问题是我不知道如何更改代码的ftp部分以使其与更改,重命名或创建的任何文件一起使用...
The application is going to be a .net desktop application, that can upload the changed file onto the ftp server. The server runs Linux. It''s with dreamhost.com
I was planning on using the system.io.filesystemwatcher, my problem is that I dont know how to change the ftp portion of my code to work with whatever file was changed, renamed or created...


这篇关于使用systemfilewatcher和ftp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆