Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
549 views
in Technique[技术] by (71.8m points)

c# - Cannot access a closed Stream of a memoryStream, how to reopen?

I have a memoryStream instance and it is closed.

I already have tried:

memoryStream.Flush();
memoryStream.Position=0;

To reopen the memory stream but it does not work. How can I reopen a closed memory stream?

question from:https://stackoverflow.com/questions/9508879/cannot-access-a-closed-stream-of-a-memorystream-how-to-reopen

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

How can I reopen a closed memory stream?

You can't reopen the stream. If you need to "reset" the stream, just assign it a new instance:

memoryStream = new MemoryStream();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...