sharp-extensions/StreamExtensions.cs

26 lines
456 B
C#
Raw Normal View History

2017-11-23 13:06:39 +01:00
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);
}
}
}