I'm getting a request from my front end to get the file.
So I have a byte array saved in my SQL DB, I it looks like to use File
result I need to return a FileStream
converted from the byte array.
I tried following MSDN to do this, using my byte array I get from my DB, but I get an error on the line
using(FileStream fileStream = new FileStream(fileName, FileMode.Create))
{
Access to the path 'C:\Program Files (x86)\IIS Express\Test.docx' is denied.
Obviously, I know what's happening. It's using the fileName
as path to find a file instead of creating a new file. Why is this happening? How do I return my byte array as a file in a FileStream? Should I even write file to disk if I need to return it in response?