I wanted to use the FileStream class to avoid saving any files on the client's computer. But every constructor of FileStream requires a path to a file.
How do I create a FileStream from a stream and not have to save it on the harddrive?
EDIT: I am already using memorystream to store my information. But at some point I need to zip the files into ANOTHER STREAM. The problem is that the zip commands (I've looked in GZipStream - It zips FILES to a STREAM) require me a source filePath(FileStream).
If I can't surpass by creating a FileStream from a stream, is there another way to zip streams?
In this scenario you should just use a MemoryStream, and ensure your API just demands Stream rather than FileStream specifically. For example:
using(var ms = new MemoryStream()) {
YourCode(ms);
}
Alternatively you could keep using FileStream by using a file in the temp area, via Path.GetTempFileName().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With