I have a byte document in a variable, and I want to put it into a FileStream
for using it into a StreamReader
.
Can I do this?
I saw that FileStream
uses a path, but is there a way to read my byte document?
I got something like this, of course, the myByteDocument
doesn't work, because it's not a path:
file = new FileStream(myByteDocument, FileMode.Open, FileAccess.Read, FileShare.Read);
reader= new StreamReader(file);
reader.BaseStream.Seek(0, SeekOrigin.Begin);
string fullText= "";
while (reader.Peek() > -1)
{
fullText+= reader.ReadLine();
}
reader.Close();
myByteDocument is obtain like this :
DataRow row = vDs.Tables[0].Rows
byte[] myByteDocument = (byte[])row.ItemArray[0];
I read the document, and put it into a string to replace, some pieces of it, and then after all the replace, I create a new document with the fullText
variable, with something like sw.write(fullText)
, where sw
is a StreamWriter
.
So, I want to read the file, without knowing the path, but with the byte document directly. Can I do this?
If I'm not clear, don't hesitate, say it.