且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在没有用户交互的情况下将文件上传到Ftp服务器?

更新时间:2022-06-08 00:07:37

假设你使用winforms或wpf你可以使用 FileSystemWatcher



Assuming your're using winforms or wpf you can use FileSystemWatcher

FileSystemWatcher fsw = new FileSystemWatcher("mydir");
fsw.Changed += new FileSystemEventHandler(fsw_Changed);
fsw.NotifyFilter = NotifyFilters.LastWrite;
fsw.EnableRaisingEvents = true;





fsw将如果文件被修改,则引发事件。

在更改事件中,您可以在托盘或任务栏中运行上传代码和通知。



也许你也想使用像这样的文件过滤器



The fsw will raise the event if the file is modified.
On the change-event, you can run your upload code and the notification in the tray or taskbar.

maybe you also want to use a filefilter like this

FileSystemWatcher fsw = new FileSystemWatcher("mydir", ".dat");