简体   繁体   English

使用 C# 以隐藏模式启动任何文件(非 exe)

[英]Start any file (Not exe) in Hidden Mode using C#

I am having a requirement to Start/Open any file (saved in disk) in hidden mode.我需要以隐藏模式启动/打开任何文件(保存在磁盘中)。
Example: "C:\\abc.txt","C:\\abc.xlsx"...示例:"C:\\abc.txt","C:\\abc.xlsx"...

I have used below code but it did't work.我使用了下面的代码,但没有用。

            ProcessStartInfo startInfo = new ProcessStartInfo();
            startInfo.CreateNoWindow = true;
            startInfo.UseShellExecute = false;
            startInfo.FileName = "excel.exe";
            startInfo.WindowStyle = ProcessWindowStyle.Hidden;
            startInfo.Arguments = @"C:\abc.xlsx";
            Process process = Process.Start(startInfo);

Is there any way to open any type of FILE in hidden mode?有没有办法在隐藏模式下打开任何类型的文件

To open a document which has an executable registered for its file type you set UseShellExecute = true.要打开已为其文件类型注册了可执行文件的文档,请设置 UseShellExecute = true。 I don't know if it works with the ProcessWindowStyleHidden WindowStyle flag though.我不知道它是否适用于 ProcessWindowStyleHidden WindowStyle 标志。 See: https://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.useshellexecute(v=vs.110).aspx请参阅: https : //msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.useshellexecute(v=vs.110).aspx

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

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