如题,用C#实现一个WinForm的窗体,里面就有一个进度条就行
主要是进度条和Timer结合实现文件的拷贝功能,
希望高手发个简单的代码。
谢谢!
主要是进度条和Timer结合实现文件的拷贝功能,
希望高手发个简单的代码。
谢谢!
解决方案 »
- GridView 最后一个输入值得不到
- 判断语句
- 求一个System.Management Namespace 的demo
- [请进] 用C#发送数据包,给一个实例马上结分
- 急!!如何利用XML在SQL2000中查询数据并在Winform中应用!!!
- 莫名其妙!There is already an open DataReader associated with this Connection which must be closed first.
- 新手报道,请高手指教,C#入门概念问题,麻烦了
- c#用API两次调用SendMessage,但参数类型不同,如何声明
- 数据库问题
- 帮帮忙:数据库修改问题,估计高手一下就能解决,我花了一天时间没解决.必须请教了.谢了.
- C#中如何获取字符串中的几个字符
- 问个C# ascx问题。我在运行一个例子.
{
Thread th = new Thread(new ThreadStart(Copy1));
th.Start();
}拷贝方法:
void Copy1()
{
int intTotalFiles=0,intCurrent=0;
intTotalFiles=获取文件总数方法();
成功拷贝一个文件();intCurrent++;
progressBar1.Value=100*(intCurrent/intTotalFiles);
}
根据:已传输的流长度/文件长度设定process
using System;
using System.IO;
class MyStream
{
private const string FILE_NAME = "Test.data";
public static void Main(String[] args)
{
// Create the new, empty data file.
if (File.Exists(FILE_NAME))
{
Console.WriteLine("{0} already exists!", FILE_NAME);
return;
}
FileStream fs = new FileStream(FILE_NAME, FileMode.CreateNew);
// Create the writer for data.
BinaryWriter w = new BinaryWriter(fs);
// Write data to Test.data.
for (int i = 0; i < 11; i++)
{
w.Write( (int) i);
//此处设定ProcessBar的position为 i/11*100%
}
w.Close();
fs.Close();
// Create the reader for data.
fs = new FileStream(FILE_NAME, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
// Read data from Test.data.
for (int i = 0; i < 11; i++)
{
Console.WriteLine(r.ReadInt32());
}
w.Close();
}
}