当先锋百科网

首页 1 2 3 4 5 6 7
using System;
using System.IO;

namespace test
{
    class demo
    {
        public void timeDelay(int iInterval)
        {
            DateTime now = DateTime.Now;
            while (now.AddMilliseconds(iInterval) > DateTime.Now)
            {
            }
            return;
        }
        static void Main(string[] args)
        {
            demo d = new demo();
            string fileName = "C:\\Users\\Chris\\Desktop\\a.bin";
            BinaryReader br;
            try
            {
                br = new BinaryReader(new FileStream(fileName, FileMode.Open));
            }
            catch (IOException e)                                             //文件打开失败
            {
                Console.WriteLine(e.Message + "\n Cannot create file.");
                return;
            }
            FileInfo f = new FileInfo(fileName);
            Console.WriteLine(f.Length);
            d.timeDelay(2000);
            Console.WriteLine(f.Length);
            byte data;
            for (int i = 0; i < f.Length; i++)
            {
                data = br.ReadByte();
                Console.Write("{0:x} ", data);
            }
  
            Console.ReadKey();
        }
    }
}