源码下载:http://dl2.csdn.net/down4/20070910/10203128242.rar
using
System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace FileWatch
... {
class Program
...{
static void Main(string[] args)
...{
byte[] bydata = new byte[100];
char[] chardata = new char[100];
try
...{
FileStream fs = new FileStream("../../Program.cs", FileMode.Open);
fs.Seek(0, SeekOrigin.Begin);
System.IAsyncResult saResult = fs.BeginRead(bydata, 0, 100, null, null);
while(!saResult.IsCompleted)
...{
Console.WriteLine("Reading From File......");
}
fs.EndRead(saResult);
Decoder d=Encoding.UTF8.GetDecoder();
d.GetChars(bydata,0,bydata.Length,chardata,0);
Console.WriteLine(chardata);
Console.ReadLine();
return;
}
catch(IOException ex)
...{
Console.WriteLine("An IO ecception has been thrown!");
Console.WriteLine(ex.ToString());
Console.ReadLine();
return;
}
return;
}
}
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace FileWatch
... {
class Program
...{
static void Main(string[] args)
...{
byte[] bydata = new byte[100];
char[] chardata = new char[100];
try
...{
FileStream fs = new FileStream("../../Program.cs", FileMode.Open);
fs.Seek(0, SeekOrigin.Begin);
System.IAsyncResult saResult = fs.BeginRead(bydata, 0, 100, null, null);
while(!saResult.IsCompleted)
...{
Console.WriteLine("Reading From File......");
}
fs.EndRead(saResult);
Decoder d=Encoding.UTF8.GetDecoder();
d.GetChars(bydata,0,bydata.Length,chardata,0);
Console.WriteLine(chardata);
Console.ReadLine();
return;
}
catch(IOException ex)
...{
Console.WriteLine("An IO ecception has been thrown!");
Console.WriteLine(ex.ToString());
Console.ReadLine();
return;
}
return;
}
}