代码如下:
[code=C#]string sPath = openFileDialog1.FileName;
FileInfo fileinfo = new FileInfo(sPath);
System.IO.FileStream fs = System.IO.File.OpenRead(sPath);
byte[] bytContent = new byte[10485760];
long fslength = fileinfo.Length;
int blockcount = (fslength / 10485760).ToInt32();
int tempcount = 0;
if (fslength % 10485760 != 0)
{
tempcount = blockcount + 1;
}
if (tempcount != 0)
{
string base64String = "";
for (int i = 0; i < blockcount; i++)
{
fs.Seek(10485760, SeekOrigin.Current);
fs.Read(bytContent, 0, 10485760);
base64String = Convert.ToBase64String(bytContent);
CallJavaScript(base64String + "|" + openFileDialog1.SafeFileName + "|" + tempcount + "|" + (i + 1));
}
fs.Seek(10485760, SeekOrigin.Current);
fs.Read(bytContent, 0, (fslength % 10485760).ToInt32());
base64String = Convert.ToBase64String(bytContent);
CallJavaScript(base64String + "|" + openFileDialog1.SafeFileName + "|" + tempcount + "|" + tempcount);
}
else
{
for (int i = 0; i < blockcount; i++)
{
fs.Read(bytContent, 0, fslength.ToInt32());
string base64String = Convert.ToBase64String(bytContent);
CallJavaScript(base64String + "|" + openFileDialog1.SafeFileName + "|" + blockcount + "|" + (i + 1));
}
}
fs.Close();
这样写提示内存不足。[/code]
[code=C#]string sPath = openFileDialog1.FileName;
FileInfo fileinfo = new FileInfo(sPath);
System.IO.FileStream fs = System.IO.File.OpenRead(sPath);
byte[] bytContent = new byte[10485760];
long fslength = fileinfo.Length;
int blockcount = (fslength / 10485760).ToInt32();
int tempcount = 0;
if (fslength % 10485760 != 0)
{
tempcount = blockcount + 1;
}
if (tempcount != 0)
{
string base64String = "";
for (int i = 0; i < blockcount; i++)
{
fs.Seek(10485760, SeekOrigin.Current);
fs.Read(bytContent, 0, 10485760);
base64String = Convert.ToBase64String(bytContent);
CallJavaScript(base64String + "|" + openFileDialog1.SafeFileName + "|" + tempcount + "|" + (i + 1));
}
fs.Seek(10485760, SeekOrigin.Current);
fs.Read(bytContent, 0, (fslength % 10485760).ToInt32());
base64String = Convert.ToBase64String(bytContent);
CallJavaScript(base64String + "|" + openFileDialog1.SafeFileName + "|" + tempcount + "|" + tempcount);
}
else
{
for (int i = 0; i < blockcount; i++)
{
fs.Read(bytContent, 0, fslength.ToInt32());
string base64String = Convert.ToBase64String(bytContent);
CallJavaScript(base64String + "|" + openFileDialog1.SafeFileName + "|" + blockcount + "|" + (i + 1));
}
}
fs.Close();
这样写提示内存不足。[/code]
CallJavaScript?
调试不到问题?
CallJavaScript或Base64转换都可能是报错的地方。
ActiveX不能调试的吧?而且我传个30M以下的就不错。奇怪了