阅读背景:

用于将文件流式传输到字节并返回的正确术语

来源:互联网 

I have the below methods:

我有以下方法:

    public static byte[] ConvertFileToBytes(string filePath)
    {
        var fInfo = new FileInfo(filePath);
        var numBytes = fInfo.Length;
        var dLen = Convert.ToDouble(fInfo.Length / 1000000);

        var fStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
        var br = new BinaryReader(fStream);

        var data = br.ReadBytes((int)numBytes);
        br.Close();

        fStream.Close();
        fStream.Dispose();

        return data;
    }

    public static void ConvertBytesToFile(byte[] file, string filePath)
    {
        var ms = new MemoryStream(file);

        var fs = new FileStream(filePath, FileMode.Create);

        ms.WriteTo(fs);

        ms.Close();
        fs.Close();
        fs.Dispose();
    }
    publi



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: