Writing byte stream
-
Hi, Iam trying to open a word document using filestream and thereby put the data in byte array by reading the filestream. Now, i want to write back the byte stream to a file like doc file, would there be any complexities by doing this? If the document has some images can it be written back to a file? code is as follows: //for reading FileStream fileStream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Read); long len; len = fileStream.Length; Byte[] fileAsByte = new Byte[len]; fileStream.Read(fileAsByte, 0, fileAsByte.Length); same logic for writing too Thanks,
gauthee
-
Hi, Iam trying to open a word document using filestream and thereby put the data in byte array by reading the filestream. Now, i want to write back the byte stream to a file like doc file, would there be any complexities by doing this? If the document has some images can it be written back to a file? code is as follows: //for reading FileStream fileStream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Read); long len; len = fileStream.Length; Byte[] fileAsByte = new Byte[len]; fileStream.Read(fileAsByte, 0, fileAsByte.Length); same logic for writing too Thanks,
gauthee
Hi, you can read all bytes of all files you can access. and you can write these bytes again to any location you can access. Since .NET 2.0 you can do it with File.ReadAllBytes and File.WriteAllBytes, you don't need streams for that. Don't really know what good it all will do for you tho. You probably will not be able to understand the bytes, nor change them in any way that results in a valid new document. And you can't just convert a document by changing its file extension, if that were what you hope for. :)
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google