• 大小: 452KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-09
  • 语言: C#
  • 标签: u盘  

资源简介

c#实现u盘操作程序,可进行对u盘的感应及安全卸载,插上u盘可对网络资源的自动下载.

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Threading;
using System.xml;

namespace WebFileDown
{
    public partial class fileDown :Form
    {
        public fileDown()
        {
            InitializeComponent();
        }
        string xmlurl = Application.StartupPath + “//fileList.xml“;
        xmlDocument document;
        public bool isExit = false;
        string downUrl = System.Configuration.ConfigurationSettings.AppSettings[“weburl“].ToString();
        private void Form1_Load(object sender EventArgs e)
        {
            document = new xmlDocument();
            document.Load(xmlurl);
            webFileDown();
            
         //   this.Hide();
          //  this.ShowInTaskbar = false; 

        }        
        float maxSpeed = 0;
        float currentSpeed = 0;
        float lastSpeed = 0;
        long lastReceive = 0;
        long reeciveSpan;
        TimeSpan span;
        DateTime start;
        DateTime lastTime;
        TimeSpan useTime;

        void webClint_DownloadProgressChanged(object sender DownloadProgressChangedEventArgs e)
        {
            try
            {
                WebClient webClint = (WebClient)sender;
                span = DateTime.Now - lastTime;
                lastTime = DateTime.Now;
                useTime = lastTime - start;
                reeciveSpan = e.BytesReceived - lastReceive;
                currentSpeed = span.Milliseconds > 0 ? reeciveSpan * 1000 / span.Milliseconds / 1024 : 0;
                maxSpeed = currentSpeed > maxSpeed ? currentSpeed : maxSpeed;
                lastSpeed = currentSpeed;
                lastReceive = e.BytesReceived;

                //label1.Text = “已下载: “ + e.BytesReceived / 1024 + “KB\n“ +
                //    “总大小: “ + e.TotalBytesToReceive / 1024 + “KB\n“ +
                //    “百分比: “ + e.ProgressPercentage + “%\n“ +
                //    “当前速度: “ + currentSpeed.ToString(“F2“) + “KB/s\n“ +
                //    “最大速度: “ + maxSpeed.ToString(“F2“) + “KB/s\n“ +
                //    “用时: “ + (useTime.Minutes * 60 + useTime.Seconds) + “s“;

                this.listView1.Items[webClint.QueryString[“path“]].SubItems[1].Text = e.BytesReceived / 1024 + “KB“;
                this.listView1.Items[webClint.QueryString[“path“]].SubItems[2].Text = e.TotalBytesToReceive / 1024 + “KB“;
                this.listView1.Items[webClint.QueryString[“path“]].SubItems[3].Text = e.ProgressPercentage + “%“;
                this.listView1.Items[webClint.QueryString[“path“]].SubItems[4].Text = currentSpeed.ToString(“F2“) + “KB/s“;
                this.listView1.Items[webClint.QueryString[“path“]].SubItems[5].Text = maxSpeed.ToString(“F2“) + “KB/s“;
                this.listView1.Items[webClint.QueryString[“path“]].SubItems[6].Text 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        953  2010-07-23 15:10  WebFileDown\WebFileDown\app.config

     文件        521  2010-08-06 11:47  WebFileDown\WebFileDown\bin\Debug\fileList.xml

     文件      69632  2010-08-06 16:52  WebFileDown\WebFileDown\bin\Debug\WebFileDown.exe

     文件        953  2010-07-23 15:10  WebFileDown\WebFileDown\bin\Debug\WebFileDown.exe.config

     文件     122368  2010-08-06 16:52  WebFileDown\WebFileDown\bin\Debug\WebFileDown.pdb

     文件       5632  2005-12-08 14:51  WebFileDown\WebFileDown\bin\Debug\WebFileDown.vshost.exe

     文件        953  2010-07-23 15:10  WebFileDown\WebFileDown\bin\Debug\WebFileDown.vshost.exe.config

     文件       8402  2010-08-06 16:52  WebFileDown\WebFileDown\fileDown.cs

     文件      12226  2010-07-16 15:13  WebFileDown\WebFileDown\fileDown.Designer.cs

     文件      13616  2010-07-16 15:13  WebFileDown\WebFileDown\fileDown.resx

     文件       6250  2010-07-16 17:20  WebFileDown\WebFileDown\FileList.cs

     文件       8899  2010-07-16 12:03  WebFileDown\WebFileDown\FileList.Designer.cs

     文件      10022  2010-07-16 12:03  WebFileDown\WebFileDown\FileList.resx

     文件       7844  2010-08-06 11:05  WebFileDown\WebFileDown\Form1.cs

     文件       7519  2010-08-06 10:54  WebFileDown\WebFileDown\Form1.Designer.cs

     文件       6008  2010-08-06 10:54  WebFileDown\WebFileDown\Form1.resx

     文件       4326  2010-08-06 14:02  WebFileDown\WebFileDown\Form2.cs

     文件       1461  2010-08-04 14:08  WebFileDown\WebFileDown\Form2.Designer.cs

     文件       5814  2010-08-04 14:08  WebFileDown\WebFileDown\Form2.resx

     文件        353  2010-08-04 16:48  WebFileDown\WebFileDown\Form3.cs

     文件        970  2010-08-04 16:48  WebFileDown\WebFileDown\Form3.Designer.cs

     文件       8795  2010-08-06 14:34  WebFileDown\WebFileDown\Library\Device.cs

     文件        960  2010-08-06 14:34  WebFileDown\WebFileDown\Library\DeviceCapabilities.cs

     文件       8962  2010-08-06 14:34  WebFileDown\WebFileDown\Library\DeviceClass.cs

     文件        610  2010-08-06 14:34  WebFileDown\WebFileDown\Library\DiskDeviceClass.cs

     文件       6762  2010-08-06 14:34  WebFileDown\WebFileDown\Library\Native.cs

     文件       7490  2010-08-06 14:34  WebFileDown\WebFileDown\Library\Volume.cs

     文件       1326  2010-08-06 14:34  WebFileDown\WebFileDown\Library\VolumeDeviceClass.cs

     文件       5120  2010-07-26 11:55  WebFileDown\WebFileDown\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll

     文件      10240  2010-07-26 11:55  WebFileDown\WebFileDown\obj\Debug\TempPE\Web References.localhost.Reference.cs.dll

............此处省略48个文件信息

评论

共有 条评论