C# 将文件流传递给 EXE 文件
我有一个文件流,我想将其传递给 EXE 进行处理。这可能吗?
using (FileStream fs = File.Create(path))
{
Addfile(fs, fileinmemory.ToString());
}
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.Arguments = Addfile //filestream from above
p.StartInfo.FileName = "load.exe"; //used withabove argument to be passed into exe
p.Start();
p.WaitForExit();
I have an a FILE STREAM that I want to pass to an EXE to be processed. Is this possible?
using (FileStream fs = File.Create(path))
{
Addfile(fs, fileinmemory.ToString());
}
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.Arguments = Addfile //filestream from above
p.StartInfo.FileName = "load.exe"; //used withabove argument to be passed into exe
p.Start();
p.WaitForExit();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
简单:
mempry 映射文件。
http://blogs.msdn.com/b/salvapatuel/archive/2009/06/08/working-with-memory-mapped-files-in-net-4.aspx
simple :
mempry mapped files.
http://blogs.msdn.com/b/salvapatuel/archive/2009/06/08/working-with-memory-mapped-files-in-net-4.aspx
我不相信这是可能的,不能直接通过命令行。
预期的参数是命令行参数,通常在基于 C# 和 C 的应用程序中,这将是一个
string[]
。如果您要使用两个进程都可以访问的文件,则需要传递文件路径(或具有预先商定的文件位置),那么您可以使用它,但这与将流传递给一个可执行文件。
I don't believe this is possible, not directly through the command line.
The arguments expected are command line arguments, normally in C# and C based applications this would be a
string[]
.If you were to use a file that was accessible to both processes you would need to pass the file path (or have a pre-agreed file location), then you could use that, but this is not the same as passing in a stream to an executable.
您可以物理创建文件并传递其路径,也可以创建内存映射文件以进行交换
You can create the file physically and pass it's path, or you can create a memory mapped file for exchange