c# 在WebClient 请求期间发生异常
在 WebClient 请求期间发生异常
第一次点击listv的一项正常播放音乐,再点击另一首就崩溃了

private void listView1_MouseClick(object sender, MouseEventArgs e)
{
itemCurrent = listView1.GetItemAt(e.X, e.Y);
filePath = itemCurrent.SubItems[5].Text.ToString();
axWindowsMediaPlayer1.URL = filePath;
axWindowsMediaPlayer1.Ctlcontrols.play();
strsFilePath = filePath.Split('/');
fileName = strsFilePath.Last().Trim();
filePathLocalDirectory = @"C:\Users\逍遥\Desktop\wav\";
filePathLocal = filePathLocalDirectory + fileName;
webClient = new WebClient();
webClient.DownloadFile(filePath, filePathLocal);
wave = new WaveFile(filePathLocal);
wave.Read();
m_DrawWave = true;
Refresh();
webClient.Dispose();
}
第一次点击listv的一项正常播放音乐,再点击另一首就崩溃了

private void listView1_MouseClick(object sender, MouseEventArgs e)
{
itemCurrent = listView1.GetItemAt(e.X, e.Y);
filePath = itemCurrent.SubItems[5].Text.ToString();
axWindowsMediaPlayer1.URL = filePath;
axWindowsMediaPlayer1.Ctlcontrols.play();
strsFilePath = filePath.Split('/');
fileName = strsFilePath.Last().Trim();
filePathLocalDirectory = @"C:\Users\逍遥\Desktop\wav\";
filePathLocal = filePathLocalDirectory + fileName;
webClient = new WebClient();
webClient.DownloadFile(filePath, filePathLocal);
wave = new WaveFile(filePathLocal);
wave.Read();
m_DrawWave = true;
Refresh();
webClient.Dispose();
}
...全文
相关推荐
c# 利用BackgroundWorker后台检测Internet连接是否可用
- 记得检查`CancellationPending`属性,以确保在后台任务执行期间可以响应取消请求。 - 当`BackgroundWorker`仍在运行时,不要尝试再次启动它,否则会引发异常。
System.Net.WebException(解决方案).md
除了WebClient,.NET还提供了其他用于处理HTTP请求的类,比如HttpClient。
C#中在WebClient中使用post发送数据实现方法
首先,让我们深入了解WebClient类。WebClient类是System.Net命名空间的一部分,它提供了多个方法来处理HTTP请求。
C# WebClient 上传文件
### C# WebClient 上传文件知识点解析#### 一、引言在开发过程中,经常会遇到需要将客户端的文件上传到服务器的需求。
C#中WebClient实现文件下载
在C#编程中,WebClient类提供了一种简单的方式来实现文件下载。WebClient是一个高度封装的网络通信类,主要用于HTTP协议交互,包括上传和下载数据。


