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

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

问题描述:

在特定目录中修改或添加文件时。

我需要将这些文件上传到FTP服务器。

在上传这些文件之前我需要显示通知底部任务栏上的图标。

提前感谢你。

When file is modified or added in a particular directory.
I need to Upload those files to FTP server.
And before Uploading those files i need to show notify icon on the bottom task bar.
Thanking you in Advance.

假设你使用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");