我正在做一个应用程序,其中我通过FTP传输文件.我成功完成了传输文件和文件夹的所有事情.现在我想知道如何在传输文件时连接或断开网络电缆时获取事件.
即时通讯使用SYSTEM.NET NAMESPACE,FTPWEBREQUEST类.
什么时候会引发事件我只是运行mi程序并断开网络电缆但没有任何反应.
我不能提出事件你将发送你的代码.实际上它是在vb.net.it没有在c#下面提出是mycode:
public partial class Form1 : Form
{
public static event NetworkAvailabilityChangedEventHandler networkchanged;
string file_to_upload;
string serverip;
string username;
string password;
FileStream fstream;
Stream strem;
public Form1()
{
InitializeComponent();
networkchanged += new NetworkAvailabilityChangedEventHandler(Form1_networkchanged);
}
void Form1_networkchanged(object sender, NetworkAvailabilityEventArgs e)
{
//my implementations goes here
//throw new Exception("The method or operation is not implemented.");
}
Run Code Online (Sandbox Code Playgroud)
我做到了这非常有用.非常感谢你