26 lines
456 B
C#
26 lines
456 B
C#
using System;
|
|
using System.IO;
|
|
using System.Text;
|
|
|
|
namespace sharp.extensions
|
|
{
|
|
public static class StreamExtensions
|
|
{
|
|
static ASCIIEncoding ascii = new ASCIIEncoding();
|
|
|
|
public static string ReadLine(this Stream stream){
|
|
MemoryStream m = new MemoryStream();
|
|
int by;
|
|
|
|
while ((by = stream.ReadByte()) != 0x0a){
|
|
if (by != 0x0d){
|
|
m.WriteByte((byte)by);
|
|
}
|
|
}
|
|
|
|
return ascii.GetString(m.GetBuffer(),0,(int)m.Length);
|
|
}
|
|
|
|
}
|
|
}
|