开发者

Access Azure Embedded Binary Resource (FileStream?)

开发者 https://www.devze.com 2023-01-30 05:17 出处:网络
I have some code that uses FileStream to quickly read from a binary file.My test project console app works great pointing at a local file.My production environment is ASP.NET MVC on Azure, and so I fi

I have some code that uses FileStream to quickly read from a binary file. My test project console app works great pointing at a local file. My production environment is ASP.NET MVC on Azure, and so I figured that I should use a resource file. Currently the code is:

var file 开发者_开发问答= new FileStream(@"c:\path\myfile.dat", FileMode.Open, FileAccess.Read);

...

Do I need to migrate the code to use something other than FileStream, or is there a way? Speed is a key requirement.


Nevermind. This was easy. I simply needed to use MemoryStream instead.
var ms = new MemoryStream(MyAssembly.Properties.Resources.Resource, false);

MemoryStream and FileStream both inherit from Stream, so the rest of the code didn't have to change...

0

精彩评论

暂无评论...
验证码 换一张
取 消