开发者

Something like System.Diagnostics.Process.Start to run a stream

I get from server images and videos by stream. Now I'm saving it:

 Stream str = client.GetFile(path);
                    using (var outStream = new FileStream(@"c:\myFile.jpg", FileMode.Create))
                    {
                        var buffer = new byte[4096];
                        int cou开发者_如何学JAVAnt;
                        while ((count = str.Read(buffer, 0, buffer.Length)) > 0)
                        {
                            outStream.Write(buffer, 0, count);
                        }
                    }

I can be jpg, mpg, flv and a lot of other multimedia types (Before I get stream I know what is a extension of this file).

Now I want to not save it , but run direct from stream.

Examples:

I get stream which is mybirthay.avi and I call my method RunFile(stream) and I think this method should works like System.Diagnostics.Process.Start(path), so my stream should be opened by default program in my SO for example allplayer.

I get stream from myfile.jpg and it is opening by irfanview,

etc...

Is it possible ??


If you are set on not saving the stream to the disk, you could use something like Eldos' Callback File System: http://www.eldos.com/cbfs/

Or, use a ramdisk, save your stream there, and shell to that file location.


Windows puts up a wall between processes so they cannot directly access each other's memory without going through privileged debug-like API functions like ReadProcessMemory. This is what keeps the operating system stable and secure. But spells doom for what you are trying to accomplish.

You'll need to use a file. It won't be much slower than direct memory access, the file system cache takes care of that.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜