Hi,
Can anyone please show me the path to proceed in order to convert memorystream to filestream and vice versa?
Thanks,
AK
Hi,
Can anyone please show me the path to proceed in order to convert memorystream to filestream and vice versa?
Thanks,
AK
I'm not sure exactly what you mean. This is how I'd do it:Code://FileStream to MemoryStream MemoryStream ms = new MemoryStream(); using (FileStream file = new FileStream("in.txt", FileMode.Open)) { int buffer; while ((buffer = file.ReadByte()) != -1) ms.WriteByte((byte)buffer); } ms.Seek(0, SeekOrigin.Begin); //MemoryStream to FileStream using (FileStream file = new FileStream("out.txt", FileMode.Create)) { int buffer; while ((buffer = ms.ReadByte()) != -1) file.WriteByte((byte)buffer); }
If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein