08-网络操作/断点续传下载文件/DownLoadFile/Form1.cs
(开头部分) 7KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;
using System.Text.RegularExpressions;
using System.Runtime.InteropServices;
namespace DownLoadFile
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string strName = "";//记录要下载的文件名
private void Form1_Load(object sender, EventArgs e)
{
try
{
//监视剪贴板是否有数据
string strPath = Clipboard.GetData(DataFormats.Text).ToString();
//验证网址格式
if (Regex.IsMatch(strPath, @"http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?"))
{
textBox1.Text = strPath;
strName = strPath.Substring(strPath.LastIndexOf("/") + 1);
}
//读取文件存放的默认路径
textBox2.Text = ReadString("SysSet", "RootPath", "", Application.StartupPath + "\\SysSet.ini");
textBox3.Text = strName;
}
catch { }
}
//下载文件
private void button1_Click(object sender, EventArgs e)
{
if (textBox2.Text.EndsWith("\\"))
DownloadFile(textBox2.Text + strName, textBox1.Text);
else
DownloadFile(textBox2.Text + "\\" + strName, textBox1.Text);
}
//选择存放路径,并存储到INI文件中
private void button4_Click(object sender, EventArgs e)
{
folderBrowserDialog1.SelectedPath = ReadString("SysSet", "RootPath", "", Application.StartupPath + "\\SysSet.ini");
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
textBox2.Text = folderBrowserDialog1.SelectedPath;
WritePrivateProfileString("SysSet", "RootPath", folderBrowserDialog1.SelectedPath, Application.StartupPath + "\\SysSet.ini");
后面还有 123 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读 AI
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
