I am a newibe of C# and async programming
thx for your help. I think most likely is my logical problem but i cant
figure it out
using System.IO;
using System.Text;
using System;
class Class1
{
static void Main()
{
Class1 a = new Class1();
a.Run();
Console.ReadLine();
}
void cB(IAsyncResult ar)
{
fsOut.EndWrite(ar);
fsIn.BeginRead(buffer,0,buffer.Length,new AsyncCallback(write),null);
}
void write(IAsyncResult ar)
{
int byteRead=fsIn.EndRead(ar);
if(byteRead==0)
{
fsOut.Write(buffer,0,buffer.Length);
fsOut.Close();
fsIn.Close();
}
else
{
fsOut.BeginWrite(buffer,0,buffer.Length,new AsyncCallback(cB),null);
}
}
public void Run()
{
fsOut = new
FileStream("Result.jpg",FileMode.Create,FileAccess .Write,FileShare.ReadWrite,2048,true);
fsIn= new
FileStream("test.jpg",FileMode.Open,FileAccess.Rea d,FileShare.ReadWrite,2048,true);
fsIn.BeginRead(buffer,0,buffer.Length,new AsyncCallback(write),null);
}
Class1()
{
buffer=new byte[2048];
}
//int LastResult;
private FileStream fsIn;
private FileStream fsOut;
byte [] buffer;
}