[C#]文件中转站程序及源码

功能介绍:

在网上看到一款名为DropPoint文件复制中转站”的工具,于是自己尝试仿写一下。并且添加一个移动文件的功能。

用来提高复制粘贴文件效率的工具,它会给你一个临时中转悬浮框,只需要将一处或多处想要复制的文件拖拽到这个悬浮框,再一次性拖拽至目的地文件夹,就能高效完成复制粘贴及移动文件。

支持拖拽多个文件到悬浮框,并显示文件数量

将悬浮窗内的文件往目标文件夹拖拽即可实现复制,适用于整理文件

主要的功能实现:

1、实现文件拖拽功能,将文件或者文件夹拖拽到软件上

2、实现文件拖拽出来,将文件或目录拖拽到指定的位置

3、实现多文件添加,包含目录及文件

4、添加软件透明背景、软件置顶、文件计数

主要源码:
文件从界面拖出并实现复制及移动功能

//定义全局变量
       ArrayList FileNum = new ArrayList();
       private Rectangle dragBox;
 
       private void label1_DragEnter(object sender, DragEventArgs e)
       {
           if (e.Data.GetDataPresent(DataFormats.FileDrop))
           {
               e.Effect = DragDropEffects.Link;
 
           }
           else
           {
               e.Effect = DragDropEffects.None;
           }
       }
 
        
       private void label1_DragDrop(object sender, DragEventArgs e)
       {
           label1.ImageIndex = 2;
 
           FileNum.Add(((Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString());
           label3.Text = "已放入" + FileNum.Count + "个文件";            
       }
        
       
       private void label1_MouseDown(object sender, MouseEventArgs e)
       {
           dragBox = new Rectangle(new Point(e.X - (SystemInformation.DragSize.Width / 2),
               e.Y - (SystemInformation.DragSize.Height / 2)), SystemInformation.DragSize);
       }
 
       private void label1_MouseMove(object sender, MouseEventArgs e)
       {
           if ((e.Button & MouseButtons.Left) == MouseButtons.Left)
           {
 
               if (dragBox != Rectangle.Empty && !dragBox.Contains(e.X, e.Y))
               {
                   if (radioButton1.Checked == true)
                   {
                       string[] files = (string[])FileNum.ToArray(typeof(string));
                       var effect = this.DoDragDrop(new DataObject(DataFormats.FileDrop, files), DragDropEffects.Copy);
                       if (effect == DragDropEffects.Copy)
                       {
                           label3.Text = "文件复制完成";
                           label1.ImageIndex = 1;
                           FileNum.Clear();
                       }
                   }
                   else if (radioButton2.Checked == true)
                   {
                       string[] files = (string[])FileNum.ToArray(typeof(string));
                       var effect = this.DoDragDrop(new DataObject(DataFormats.FileDrop, files), DragDropEffects.Move);
                       if (effect == DragDropEffects.Move)
                       {
                           label3.Text = "文件移动完成";
                           label1.ImageIndex = 1;
                           FileNum.Clear();
                       }
                   }
 
               }
           }
       }
 
       private void label1_MouseUp(object sender, MouseEventArgs e)
       {
           dragBox = Rectangle.Empty;
       }

文件及源码下载地址:

链接:https://pan.baidu.com/s/184LoXj68FBGWvKe3U7iMeQ

提取码:6mc8

本来是投稿注册用的,前天开放注册了,目前重发下

链接失效了,重新上传附件

© 版权声明
THE END
如果内容对您有所帮助,就支持一下吧!
点赞0 分享
评论 共10条

请登录后发表评论