资源简介
C# winform文件复制 带进度条 类似于windows
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace CopyFiles
{
//http://www.pinvoke.net/default.aspx/kernel32.CopyFileEx
///
/// Copies a list of files or a directory tree to a destination
///
/// Support for GUI is implamented by the ICopyFilesDiag interface
/// and passed to the class in the copy() method.
///
public class CopyFiles
{
// Variables
private List files = new List();
private List newFilenames = new List();
private List filesCopied = new List();
private Int32 totalFiles = 0;
private Int32 totalFilesCopied = 0;
private String destinationDir = ““;
private String sourceDir = ““;
private String currentFilename;
private Boolean cancel = false;
private IAsyncResult CopyResult;
private DEL_CopyFiles delCopy;
private ICopyFilesDiag digWindow;
// Structurs
public struct ST_CopyFileDetails
{
String OriginalURI;
String NewURI;
// Constructor
public ST_CopyFileDetails(String FromURI String ToURI)
{
OriginalURI = FromURI;
NewURI = ToURI;
}
}
// Enums
// These Enums are used for the windows CopyFileEx function
[Flags]
private enum CopyFileFlags : uint
{
COPY_FILE_FAIL_IF_EXISTS = 0x00000001
COPY_FILE_RESTARTABLE = 0x00000002
COPY_FILE_OPEN_SOURCE_FOR_WRITE = 0x00000004
COPY_FILE_ALLOW_DECRYPTED_DESTINATION = 0x00000008
}
private enum CopyProgressResult : uint
{
PROGRESS_CONTINUE = 0
PROGRESS_CANCEL = 1
PROGRESS_STOP = 2
PROGRESS_QUIET = 3
}
private enum CopyProgressCallbackReason : uint
{
CALLBACK_CHUNK_FINISHED = 0x00000000
CALLBACK_STREAM_SWITCH = 0x00000001
}
// Events
public event DEL_copyComplete EV_copyComplete;
public event DEL_copyCanceled EV_copyCanceled;
// Delegates
private delegate CopyProgressResult CopyProgressRoutine(Int64 TotalFileSize Int64 TotalBytesTransferred Int64 StreamSize Int64 StreamBytesTransferred UInt32 dwStreamNumber CopyProgressCallbackReason dwCallbackReason IntPtr hSourceFile IntPtr hDestinationFile IntPtr lpData);
private delegate CopyProgressResult DEL_CopyProgressHandler(Int64 total Int64 transferred Int64 streamSize Int64 StreamByteTrans UInt32 dwStreamNumber CopyProgressCallbackReason reason IntPtr hSourceFile IntPtr hDestinationFile IntPtr lpData);
private delegate void DEL_CopyFiles();
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 0 2009-03-05 17:43 CopyFiles\Copy Test Folder\Bob.txt
文件 0 2009-03-05 17:43 CopyFiles\Copy Test Folder\test.txt
文件 0 2009-03-05 17:43 CopyFiles\Copy Test Folder\Test1\B.o.b.Trev..txt
文件 0 2009-03-05 17:43 CopyFiles\Copy Test Folder\Test1\Bob.Trev.txt
文件 0 2009-03-05 17:43 CopyFiles\Copy Test Folder\Test1\test.txt
文件 0 2009-03-05 17:43 CopyFiles\Copy Test Folder\Test2\Bob.Trev.txt
文件 0 2009-03-05 17:43 CopyFiles\Copy Test Folder\Test2\test.txt
文件 0 2009-03-05 17:43 CopyFiles\Copy Test Folder\Test3\B.o.b.Trev..txt
文件 0 2009-03-05 17:43 CopyFiles\Copy Test Folder\Test3\Bob.Trev.txt
文件 0 2009-03-05 17:43 CopyFiles\Copy Test Folder\Test3\test.txt
文件 0 2009-03-05 17:43 CopyFiles\Copy Test Folder\Test4\Bob.Trev.txt
文件 0 2009-03-05 17:43 CopyFiles\Copy Test Folder\Test4\test.txt
文件 16967 2009-05-22 09:34 CopyFiles\CopyFiles\Backup\CopyFiles\CopyFiles.cs
文件 3015 2009-05-22 09:38 CopyFiles\CopyFiles\Backup\CopyFiles\CopyFiles.csproj
文件 1673 2009-05-22 09:45 CopyFiles\CopyFiles\Backup\CopyFiles\DIA_CopyFiles.cs
文件 4432 2009-05-22 09:44 CopyFiles\CopyFiles\Backup\CopyFiles\DIA_CopyFiles.Designer.cs
文件 5814 2009-05-22 09:44 CopyFiles\CopyFiles\Backup\CopyFiles\DIA_CopyFiles.resx
文件 1462 2009-05-22 09:33 CopyFiles\CopyFiles\Backup\CopyFiles\Properties\AssemblyInfo.cs
文件 1395 2009-05-22 09:40 CopyFiles\CopyFiles\Backup\CopyFiles.sln
文件 2543 2009-05-22 09:52 CopyFiles\CopyFiles\Backup\TestCopy\Form1.cs
文件 2116 2009-05-22 09:40 CopyFiles\CopyFiles\Backup\TestCopy\Form1.Designer.cs
文件 5814 2009-05-22 09:40 CopyFiles\CopyFiles\Backup\TestCopy\Form1.resx
文件 500 2009-05-22 09:39 CopyFiles\CopyFiles\Backup\TestCopy\Program.cs
文件 1460 2009-05-22 09:39 CopyFiles\CopyFiles\Backup\TestCopy\Properties\AssemblyInfo.cs
文件 2845 2009-05-22 09:39 CopyFiles\CopyFiles\Backup\TestCopy\Properties\Resources.Designer.cs
文件 5612 2009-05-22 09:39 CopyFiles\CopyFiles\Backup\TestCopy\Properties\Resources.resx
文件 1093 2009-05-22 09:39 CopyFiles\CopyFiles\Backup\TestCopy\Properties\Settings.Designer.cs
文件 249 2009-05-22 09:39 CopyFiles\CopyFiles\Backup\TestCopy\Properties\Settings.settings
文件 3942 2009-05-22 09:52 CopyFiles\CopyFiles\Backup\TestCopy\TestCopy.csproj
文件 17920 2015-09-25 17:00 CopyFiles\CopyFiles\CopyFiles\bin\Debug\CopyFiles.dll
............此处省略75个文件信息
- 上一篇:C#做的随机分组小程序亦可用于抽签摇奖
- 下一篇:C#员工管理信息系统
相关资源
- USB 发送和接收数据
- C#_winform_多个窗体之间相互传递数据操
- C#_winform_DataGridView_checkbox复选框_实现
- 生产管理系统 (VS2008 C# winform )
- 中英文切换
- c#寻找最优解
- winform打印窗体源代码
- C#完整精美时间计时和倒计时软件(带
- c# winform写的一个颜色拾取工具(原创
- Winform窗体动画载入和退出
- C# Winform 发票信息修改 文本内容修改
- C# Winform 左侧菜单右边显示、子窗体显
- C#WinForm版 《仿360杀毒页面切换动画效
- C# winform/web导出EXCEL
- WInform LED 时钟显示源码及Dll C#控件
- C#利用Remoting实现文件上传
- c#winform开发仓库管理系统,vs2010,m
- C#版winform中使用的ToggleButton
- winform用tabcontrol切换mdi子窗口及为ta
- C#中使用ACCESS数据库进行查询WinForm程
- ComponentOne 2014 V1 WinForms 注册机
- C#WinForm的ComboBox控件自定义实现自动模
- 新浪新闻RSS阅读器C#版
- 基于winform的SVG编辑器
- Winform版 简单的打字游戏c#
- C# WEB/HTTP大文件与文件夹上传2
-
微软DSOfr
amer winform中嵌入officeexcel, - WPF 环形进度条
- C#中英文切换,实现菜单,工具栏,按
- c# winform 多线程测试(初学)
评论
共有 条评论