asp.net 使用ajax
时间:2010-12-14
来源:互联网
我在网上看到一个例子http://blog.csdn.net/ljy090811/archive/2010/03/04/5346405.aspx,照着做了一下,一切正常,之后把例子的后台函数替换成我的代码:
OpenFile(int start, int length)
try
{
fs = new FileStream(strFileName, FileMode.Open, FileAccess.Read, FileShare.Read);
PlayStreams = new byte[length];// i = (int)fs.Length;
fs.Seek(start, SeekOrigin.Current);
read = fs.Read(PlayStreams, 0, length);
// sChar = Encoding.ASCII.GetChars(PlayStreams);
// i++;
aaaa = Encoding.UTF8.GetString(PlayStreams);
}
catch
{
}
fs.Close();
return aaaa;
}
我发现,当我读取起始值start为0时的文件,js输出为空,当start为40或其他值的时候就是具体值,这是为什么
OpenFile(int start, int length)
try
{
fs = new FileStream(strFileName, FileMode.Open, FileAccess.Read, FileShare.Read);
PlayStreams = new byte[length];// i = (int)fs.Length;
fs.Seek(start, SeekOrigin.Current);
read = fs.Read(PlayStreams, 0, length);
// sChar = Encoding.ASCII.GetChars(PlayStreams);
// i++;
aaaa = Encoding.UTF8.GetString(PlayStreams);
}
catch
{
}
fs.Close();
return aaaa;
}
我发现,当我读取起始值start为0时的文件,js输出为空,当start为40或其他值的时候就是具体值,这是为什么
作者: yan20054517 发布时间: 2010-12-14
C# code
using System; using System.IO; class FStream { static void Main() { const string fileName = "Test#@@#.dat"; // Create random data to write to the file. byte[] dataArray = new byte[100000]; new Random().NextBytes(dataArray); using(FileStream fileStream = new FileStream(fileName, FileMode.Create)) { // Write the data to the file, byte by byte. for(int i = 0; i < dataArray.Length; i++) { fileStream.WriteByte(dataArray[i]); } // Set the stream position to the beginning of the file. fileStream.Seek(0, SeekOrigin.Begin); // Read and verify the data. for(int i = 0; i < fileStream.Length; i++) { if(dataArray[i] != fileStream.ReadByte()) { Console.WriteLine("Error writing data."); return; } } Console.WriteLine("The data was written to {0} " + "and verified.", fileStream.Name); } } }
作者: yhtapmys 发布时间: 2010-12-14
我也遇到过 楼主相同的问题!!!filestream读取的时候貌似是从1开始的 我个人理解是这样 改成1和以后的值都没有问题
作者: pm90125 发布时间: 2010-12-14
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28