binarywriter

Why a BinaryWriter closes the outer Stream on disposal, and how to prevent that? (.NET C#)

I have one method that receives a Stream to write on it using a BinaryWriter. But when I dispose this BinaryWriter it also closes the stream. Can I leave it undisposed so I can leave my stream open? ...

VB.net BinaryWriter Problem

Hi, In c# i could do it like: send.Write((ushort)9); "send" is an instance of BinaryWriter, how can i do it in vb.net ? I've tried it like: send.Write((UShort)9) but i get "UShort is a type and cannot be used as an expression" Thanks! ...

Why does BinaryWriter prepend gibberish to the start of a stream? How do you avoid it?

I'm debugging some issues with writing pieces of an object to a file and I've gotten down to the base case of just opening the file and writing "TEST" in it. I'm doing this by something like: static FileStream fs; static BinaryWriter w; fs = new FileStream(filename, FileMode.Create); w = new BinaryWriter(fs); w.Write("test"); w.Close...

classic asp: display jpg using response.BinaryWrite

hi, i'm displaying an image like this: <img src='counter.asp'> counter.asp is doing a hitcounter do determine how often the image was displayed (i'll replace it with a modrewrite url). the problem: in the counter.asp script i need to send the actual .jpg image to the browser, how could this be done? i suppose i need to load the imag...

Excel 2007 file writer in C# results in a corrupt file

Hi, I am using a BinaryReader to read an Excel 2007 file from an Exchange mailbox using a OWA, the file is then written to disk using a BinaryWriter. My problem is that the two files don't match when the writer finishes. Worse still Excel 2007 won't open the writen file. Previously Excel 2003 has had no problem with the solution belo...

Does binarywriter.flush() also flush the underlying filestream object?

I have got a code snippet as follows: Dim fstream = new filestream(some file here) dim bwriter = new binarywriter(fstream) while not end of file read from source file bwriter.write() bwriter.flush() end while The question I have is the following. When I call bwriter.flush() does it also flush the fstream object? Or should ...

Can't write to file using binarywriter

Why does this code not write my string to the file: string file = "Myfile.txt"; MemoryStream ms = new MemoryStream(); void writeToFile(string text) { System.Text.ASCIIEncoding encoding=new System.Text.ASCIIEncoding(); byte[] barr = encoding.GetBytes(text); ms.Write(barr, 0, barr.L...

binarywriter not opening file at end of stream.

Hi, I have a method which uses a binarywriter to write a record consisting of few uints and a byte array to a file. This method executes about a dozen times a second as part of my program. The code is below: iLogFileMutex.WaitOne(); using (BinaryWriter iBinaryWriter = new BinaryWriter(File.Open(iMainLogFilename, FileMode.OpenOrCreate,...