公司禁用用迅雷,禁用所有P2P协议的软件,自己写个断点续传的工具

简介: 目前仅支持HTTP协议 下一步的工作是支持FTP协议 再下一步的工作是对原始URL进行智能分析 发此文以抗议像吉日兄这样的总监或者老板   Code    public partial class Form1 : Form    {        public Form1()      ...

目前仅支持HTTP协议

下一步的工作是支持FTP协议

再下一步的工作是对原始URL进行智能分析

发此文以抗议像吉日兄这样的总监或者老板

 

img_1c53668bcee393edac0d7b3b3daff1ae.gif img_405b18b4b6584ae338e0f6ecaf736533.gif Code
    public partial class Form1 : Form
    {
        
public Form1()
        {
            InitializeComponent();            
        }
        
private void DownLoad()
        {
            XmlDocument xmlDoc 
= new XmlDocument();
            xmlDoc.Load(
"D:\\中转\\data.xml");
            XmlNodeList nodeList 
= xmlDoc.SelectSingleNode("data").ChildNodes;
            XmlElement xe 
= (XmlElement)nodeList.Item(nodeList.Count - 1);
            
if (xe.GetAttribute("is_finish").Equals("true"))
            {
                MessageBox.Show(
"none task in the list");
                
return;
            }
            
string StrFileName = "D:\\中转\\" + xe.GetAttribute("name"); 
            
string StrUrl = xe.GetAttribute("address");

            
long lStartPos = 0;
            System.IO.FileStream fs;
            
if (System.IO.File.Exists(StrFileName))
            {
                fs 
= System.IO.File.OpenWrite(StrFileName);
                lStartPos 
= fs.Length;
                fs.Seek(lStartPos, System.IO.SeekOrigin.Current); 
//移动文件流中的当前指针
            }
            
else
            {
                fs 
= new System.IO.FileStream(StrFileName, System.IO.FileMode.Create);
                lStartPos 
= 0;
            }
            
//打开网络连接
            try
            {
                System.Net.HttpWebRequest request 
= (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(StrUrl);
                
if (lStartPos > 0)
                    request.AddRange((
int)lStartPos); //设置Range值
                
//向服务器请求,获得服务器回应数据流
                System.IO.Stream ns = request.GetResponse().GetResponseStream();
                
byte[] nbytes = new byte[512];
                
int nReadSize = 0;
                nReadSize 
= ns.Read(nbytes, 0512);                
                
while (nReadSize > 0)
                {
                    fs.Write(nbytes, 
0, nReadSize);
                    nReadSize 
= ns.Read(nbytes, 0512);
                }
                fs.Close();
                ns.Close();
                EditNode();
                MessageBox.Show(
"Down Ok!");
            }
            
catch (Exception ex)
            {
                fs.Close();
                MessageBox.Show(
"Down Error!");
            }
        }
        
private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
        {
            XmlDocument xmlDoc 
= new XmlDocument();
            xmlDoc.Load(
"D:\\中转\\data.xml");
            XmlNodeList nodeList 
= xmlDoc.SelectSingleNode("data").ChildNodes;
            XmlElement xe 
= (XmlElement)nodeList.Item(nodeList.Count - 1);
            
string StrFileName = "D:\\中转\\" + xe.GetAttribute("name");
            FileInfo fi 
= new FileInfo(StrFileName);
            DialogResult dr 
= MessageBox.Show(thisstring.Format("already:{0}kb\nOK:exit\ncancel:continue", fi.Length / 1024), "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question,MessageBoxDefaultButton.Button2);
            
if (!dr.Equals(DialogResult.Cancel))
            {
                
this.Close();
                
this.Dispose();
            }
        }

        
private void button1_Click(object sender, EventArgs e)
        {
            
this.Hide();
            
if (!string.IsNullOrEmpty(textBox1.Text.Trim())&&!string.IsNullOrEmpty(textBox2.Text.Trim()))
            {
                InsertNode();
            }
            System.Threading.Thread obj 
= new System.Threading.Thread(new System.Threading.ThreadStart(this.DownLoad));
            
//设置为前台线程,即使主方法执行结束了我的线程仍在执行
            obj.IsBackground = true;
            obj.Start();
        }
        
private void EditNode()
        {
            XmlDocument xmlDoc 
= new XmlDocument();
            xmlDoc.Load(
"D:\\中转\\data.xml");
            XmlNodeList nodeList 
= xmlDoc.SelectSingleNode("data").ChildNodes;
            XmlElement xe 
= (XmlElement)nodeList.Item(nodeList.Count - 1);
            xe.SetAttribute(
"is_finish""true");
            xmlDoc.Save(
"D:\\中转\\data.xml");//保存。
        }
        
private void InsertNode()
        {
            XmlDocument xmlDoc 
= new XmlDocument();
            xmlDoc.Load(
"D:\\中转\\data.xml");
            XmlNode root 
= xmlDoc.SelectSingleNode("data");
            XmlElement xe1 
= xmlDoc.CreateElement("file");
            xe1.SetAttribute(
"name", textBox1.Text.Trim());
            xe1.SetAttribute(
"address", textBox2.Text.Trim());
            xe1.SetAttribute(
"is_finish""false");
            root.AppendChild(xe1);
            xmlDoc.Save(
"D:\\中转\\data.xml");
        }
目录
相关文章
|
4月前
|
安全 定位技术 数据安全/隐私保护
FileZilla软件的下载、服务器站点配置与数据传输方法
FileZilla软件的下载、服务器站点配置与数据传输方法
Office软件打开速度慢的解决:禁用加载项
本文介绍基于修改加载项,解决Microsoft Office系列软件开启速度较慢的办法~
457 1
Office软件打开速度慢的解决:禁用加载项
|
数据安全/隐私保护 Windows
Windows操作系统:测试模式禁用数字签名
程序必须在特殊的启动环境下才能正常使用,尤其是一些非官方或者需要数字签名的驱动程序,而Windows测试模式可以帮助我们解决类似的问题,开启后会帮助我们禁用驱动程序强制签名
289 0
Windows操作系统:测试模式禁用数字签名
|
安全 JavaScript 前端开发
又被野外利用了!新曝光Office产品多个远程命令执行漏洞分析
本文讲的是又被野外利用了!新曝光Office产品多个远程命令执行漏洞分析,早在2015年,FireEye曾发布过两次关于Office的Encapsulated PostScript (EPS)图形文件的漏洞攻击的研究分析,其中一次属于零日漏洞攻击。
1692 0