none
MP3文件的读取 RRS feed

答案

  • 没有不同

    [C#]

    using System.IO;
    
    public static byte[] ReadFile(string filePath)
    {
     byte[] buffer;
     FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
     try
     {
      int length = (int)fileStream.Length; // get file length
      buffer = new byte[length];      // create buffer
      int count;              // actual number of bytes read
      int sum = 0;             // total number of bytes read
    
      // read until Read method returns 0 (end of the stream has been reached)
      while ((count = fileStream.Read(buffer, sum, length - sum)) > 0)
       sum += count; // sum is a buffer offset for next reading
     }
     finally
     {
      fileStream.Close();
     }
     return buffer;
    }
    
    
    2011年4月17日 7:35
  • 您好

    沒有什麼不同,請參考

    [C#]取得檔案內容中的詳細資料


    歡迎參觀我的Blog.NET菜鳥自救會
    2011年4月17日 13:05

全部回复

  • 没有不同

    [C#]

    using System.IO;
    
    public static byte[] ReadFile(string filePath)
    {
     byte[] buffer;
     FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
     try
     {
      int length = (int)fileStream.Length; // get file length
      buffer = new byte[length];      // create buffer
      int count;              // actual number of bytes read
      int sum = 0;             // total number of bytes read
    
      // read until Read method returns 0 (end of the stream has been reached)
      while ((count = fileStream.Read(buffer, sum, length - sum)) > 0)
       sum += count; // sum is a buffer offset for next reading
     }
     finally
     {
      fileStream.Close();
     }
     return buffer;
    }
    
    
    2011年4月17日 7:35
  • 您好

    沒有什麼不同,請參考

    [C#]取得檔案內容中的詳細資料


    歡迎參觀我的Blog.NET菜鳥自救會
    2011年4月17日 13:05