H
hlei
Unregistered / Unconfirmed
GUEST, unregistred user!
源码:
using System;
using System.IO;
public class MyClass
{
static byte[] b;
static FileStream sfs;
static FileStream dfs;
public static void Main()
{
fun();
}
private static void fun()
{
b = new byte[1024];
sfs = File.Open(@"F:/1.exe",FileMode.Open);
dfs = File.Create(@"F:/2.exe");
sfs.begin
Read(b,0,1024,new AsyncCallback(myCallBack),null);
//开始异步读
}
static void myCallBack(IAsyncResult ar)
{
int count = sfs.EndRead(ar);
//等待挂起的异步读取完成
if(count>0)
{
dfs.Write(b,0,count);
sfs.begin
Read(b,0,1024,new AsyncCallback(myCallBack),null);
}
else
{
dfs.Close();
sfs.Close();
}
}
}
//源码大概意思就是复制1.exe到2.exe,可是当1.exe文件大于8,515,584字节时就出错,提示溢出错误
using System;
using System.IO;
public class MyClass
{
static byte[] b;
static FileStream sfs;
static FileStream dfs;
public static void Main()
{
fun();
}
private static void fun()
{
b = new byte[1024];
sfs = File.Open(@"F:/1.exe",FileMode.Open);
dfs = File.Create(@"F:/2.exe");
sfs.begin
Read(b,0,1024,new AsyncCallback(myCallBack),null);
//开始异步读
}
static void myCallBack(IAsyncResult ar)
{
int count = sfs.EndRead(ar);
//等待挂起的异步读取完成
if(count>0)
{
dfs.Write(b,0,count);
sfs.begin
Read(b,0,1024,new AsyncCallback(myCallBack),null);
}
else
{
dfs.Close();
sfs.Close();
}
}
}
//源码大概意思就是复制1.exe到2.exe,可是当1.exe文件大于8,515,584字节时就出错,提示溢出错误