Read file into Memory Stream
MemoryStream SourceXmlMemoryStream = new MemoryStream(File.ReadAllBytes(filename));
Write File From Memory Stream
FileStream file = new FileStream(filename, FileMode.Create, FileAccess.Write); //Overwrite the existing file
OutputXmlMemoryStream.WriteTo(file);
file.Close();
OutputXmlMemoryStream.Close();
Seek
SourceXmlMemoryStream.Seek(0, SeekOrigin.Begin);
or
SourceXmlMemoryStream.Position = 0
Close Memory Stream
SourceXmlMemoryStream.Dispose();
Write MemoryStream To File
(Overwrite if alreads exists)
MemoryStream1.Position = 0;
System.IO.File.WriteAllBytes("C:\\_Downloaded\\test1.bin", MemoryStream1.ToArray());
Convert Memory Stream to String
string MyString = Encoding.UTF8.GetString(MyMemoryStream.ToArray());
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.