Using FileStream without an actual file

I wanted to use the FileStream class to avoid saving any files to the client computer. But every FileStream constructor requires a path to the file.

How to create a FileStream from a stream and not save it to your hard drive?

EDIT: I already use memystream to store my information. But at some point I need to zip files into ANOTHER FLOW. The problem is that the zip commands (I looked at GZipStream - it fastens the FILES to STREAM) requires me to file filePath (FileStream).

If I can not excel by creating a FileStream from a stream, is there any other way for zip streams?

+5
source share
3 answers

MemoryStream, , API Stream, FileStream. :

using(var ms = new MemoryStream()) {
     YourCode(ms);
}

FileStream, temp, Path.GetTempFileName().

+9

(, MemoryStream) FileStream, ( , ).

+1

FileStream works with files. You cannot change this behavior.

You can check other Stream classes inherited from System.IO.Stream, for example, MemoryStream .

0
source

All Articles