Convert a file to stream
-
Hello I want convert a file into a stream. I do it like this: FileInfo fl = new FileInfo(@"C:\test.wav"); Stream sm = fl.Open(FileMode.Open); But I do not think this is the best way to do it! Can someone tell me if this is a good way, or maybe tell me a better way of how to do this? Thanks QzRz
-
Hello I want convert a file into a stream. I do it like this: FileInfo fl = new FileInfo(@"C:\test.wav"); Stream sm = fl.Open(FileMode.Open); But I do not think this is the best way to do it! Can someone tell me if this is a good way, or maybe tell me a better way of how to do this? Thanks QzRz
This is a good way, but the FileInfo object is not necessary (unless you are using it somewhere else). Try this:
Stream sm = new FileStream(@"C:\test.wav", FileMode.Open);
Hope this helps, DigitalKing
-
This is a good way, but the FileInfo object is not necessary (unless you are using it somewhere else). Try this:
Stream sm = new FileStream(@"C:\test.wav", FileMode.Open);
Hope this helps, DigitalKing
-
Hello I want convert a file into a stream. I do it like this: FileInfo fl = new FileInfo(@"C:\test.wav"); Stream sm = fl.Open(FileMode.Open); But I do not think this is the best way to do it! Can someone tell me if this is a good way, or maybe tell me a better way of how to do this? Thanks QzRz
What DigitalKing said, but you could also use the
using
statement to close the stream and release resources correctly. Something likeusing (Stream s = ...)
{}
Regards Senthil _____________________________ My Blog | My Articles | My Flickr | WinMacro