gpt4 book ai didi

c# - 每当连接或断开网络电缆时如何获取事件

转载 作者:行者123 更新时间:2023-11-30 13:29:23 25 4
gpt4 key购买 nike

我正在做一个通过 FTP 传输文件的应用程序。我成功地完成了所有工作传输文件和文件夹的东西。现在我想知道如何在正在传输文件时连接或断开网络电缆。

我正在使用 SYSTEM.NET NAMESPACE,FTPWEBREQUEST 类。

事件什么时候引发我只是运行mi程序并断开网线但什么也没发生。

我无法引发事件,你会发送你的代码吗。实际上它在 vb.net 中工作。它不会在 c# 中引发,下面是我的代码:

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.");
}

我做到了这非常有用。非常感谢

最佳答案

关于c# - 每当连接或断开网络电缆时如何获取事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1387650/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com