- 使用CharrArray固定大小来存储结果 - 从FileLen
计算它
- 使用了Bf尺寸因子6 - 6字节 - > 8人权委员会
char[] ChArr;
string Fname = @"File Location ...";
byte[] bf = new byte[0x60000]; // 128k * 3 - 6 Bytes -> 8 Asc64 chr
int pout = 0;
int pin = 0;
using (FileStream Fs = new FileStream(Fname, FileMode.Open, FileAccess.Read))
{
int TotalBytes = (int)Fs.Length;
ChArr = new char[(int)(Math.Ceiling (TotalBytes/3)) * 4];
while (pin < TotalBytes)
{
int bytesRead = Fs.Read(bf, 0, bf.Length);
if (bytesRead <= 0) throw new Exception("Bof Found");
int bw = Convert.ToBase64CharArray(bf, 0, bytesRead, ChArr, pout);
pin += bytesRead;
pout += bw;
}
}
string s = new string(ChArr, 0, pout);
来源
2010-07-17 06:36:00
x77
它会像'while'循环,与文件读取操作和编码步骤(和IIRC您需要选择正确的块大小,或Base64编码将无效)配对。问题到底在哪里,到目前为止你有什么? – stakx 2010-07-16 18:28:07