using(System.IO.StreamReader sr = new System.IO.StreamReader(temp_path))
{
//没有到达文件结尾时一直读取文件
while(sr.Peek() > 0)
{
//读出一行文本,这里因为要按原来格式输出,所以换行还要保留。
string temp_string = sr.ReadLine();
//进行编码转换,原ASCI码转换成Unicode编码
System.Text.UnicodeEncoding unicode = new System.Text.UnicodeEncoding(); byte[] ByteArray = unicode.GetChars((temp_string);
temp_string = string.Empty;
//这个读取字节数组好像不对,但又不知道怎么转换成字符串
for(int i=0;i<ByteArray.Length;i++)
{
temp_string +=ByteArray[i].ToString();
}
//连接到输出文件内容中
file_context += temp_string + "<BR>";
}
}
{
//没有到达文件结尾时一直读取文件
while(sr.Peek() > 0)
{
//读出一行文本,这里因为要按原来格式输出,所以换行还要保留。
string temp_string = sr.ReadLine();
//进行编码转换,原ASCI码转换成Unicode编码
System.Text.UnicodeEncoding unicode = new System.Text.UnicodeEncoding(); byte[] ByteArray = unicode.GetChars((temp_string);
temp_string = string.Empty;
//这个读取字节数组好像不对,但又不知道怎么转换成字符串
for(int i=0;i<ByteArray.Length;i++)
{
temp_string +=ByteArray[i].ToString();
}
//连接到输出文件内容中
file_context += temp_string + "<BR>";
}
}
应该是getByte()写错了……
??
System.Text.Encoding.UTF8.GetString(ByteArray)
System.Text.Encoding.UTF8.GetString(ByteArray)
试问我怎么得到ByteArray?RealLine出来的是个字符串,怎么转换成ByteArray?