简体   繁体   English

像System.Diagnostics.Process.Start之类的东西来运行流

[英]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 count;
                        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). 我可以是jpg,mpg,flv和许多其他多媒体类型(在获得流之前,我知道此文件的扩展名是什么)。

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. 我得到的流是mybirthay.avi,并调用我的方法RunFile(stream),我认为此方法应类似于System.Diagnostics.Process.Start(path),因此应在我的SO中通过默认程序打开我的流,例如allplayer。

I get stream from myfile.jpg and it is opening by irfanview, 我从myfile.jpg接收流,并由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/ 如果设置为不将流保存到磁盘,则可以使用Eldos的回叫文件系统之类的方法: http ://www.eldos.com/cbfs/

Or, use a ramdisk, save your stream there, and shell to that file location. 或者,使用ramdisk,将流保存在那里,然后将shell封装到该文件位置。

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. Windows在进程之间建立了隔离墙,因此它们无法直接访问彼此的内存,而无需通过像ReadProcessMemory这样的特权调试类API函数。 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. 它不会比直接内存访问慢很多,文件系统缓存会解决这一问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM