I have a javascript file as an embedded resource in an assembly, and I'm trying to use the Stream from "System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("someName");" to create a new FileInfo object. My confusion is how to use a stream to create the FileInfo. If anyone can开发者_开发技巧 help me in this I would be greatly appreciative. I'm sure it's probably something easy, but easy is usually what I always seem to miss.
You can't. Because you have a Stream, and FileStream inherits from Stream, it doesn't mean that all Stream instances are FileStream instances (and by extension, have files that are the source of the Stream).
That being said, it doesn't make sense that the Stream returned from the call to GetManifestResourceStream would have a FileInfo associated with it, just like a NetworkStream wouldn't have a FileInfo instance associated with it either.
You have to create the file, then read the resource stream, and write the file stream.
If you really need a FileInfo, then you'll probably have to copy the data from your embedded resource out to a file on the file system. This question has some sample code.
精彩评论