无法使用C#隐藏通过cmd的文件 [英] can't hide file of through cmd using c#

查看:139
本文介绍了无法使用C#隐藏通过cmd的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿.
我试图通过cmd命令将正在c#Windows窗体中执行的两个文件隐藏在闪存驱动器中,这是代码:

hey there.
i am trying to hide two file in my flash drive through cmd command that are being executed in c# windows form here is the code:

System.Diagnostics.Process process1 = new System.Diagnostics.Process();
           System.Diagnostics.ProcessStartInfo startInfo1 = new System.Diagnostics.ProcessStartInfo();
           startInfo1.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
           startInfo1.FileName = "cmd.exe";
           startInfo1.Arguments = "attrib  +s +h G:\\autorun.inf";
           process1.StartInfo = startInfo1;
           process1.Start();



我也尝试过这个



i have also tried this one

System.Diagnostics.Process.Start("cmd", "attrib  +s +h G:\\autorun.inf");



但是我不工作.
请告诉我隐藏文件需要做什么
在此先感谢



But i does not work.
Please tell me what i need to do to hide the file
Thanks in advance

推荐答案

如果要使用cmd运行进程,请不要启动
cmd属性+ s + h G:\ autorun.inf
开始于:
cmd /c attrib + s + h G:\ autorun.inf
因此,请在C#中执行此操作:
If you want to run a process using the cmd, don''t start
cmd attrib +s +h G:\autorun.inf
Start this:
cmd /c attrib +s +h G:\autorun.inf
So, do this in C#:
System.Diagnostics.Process process1 = new System.Diagnostics.Process();
            System.Diagnostics.ProcessStartInfo startInfo1 = new System.Diagnostics.ProcessStartInfo();
            startInfo1.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            startInfo1.FileName = "cmd.exe";
            startInfo1.Arguments = "/c attrib  +s +h G:\\autorun.inf";
            process1.StartInfo = startInfo1;
            process1.Start();



希望这会有所帮助.



Hope this helps.


隐藏"文件完全没有用.任何人所需要做的就是打开资源管理器"选项,以显示隐藏的文件",它将尽职地显示您尝试使用该方法隐藏"的每个文件.

您甚至无法从CMD提示中隐藏它们.您所需要做的就是键入"dir/a"以查看隐藏"文件.
"Hiding" a file is utterly useless. All anyone has to do is turn on the Explorer option to "Show hidden files" and it''ll dutifully show every file you tried to "hide" using that method.

You can''t even hide them from a CMD prompt. All you have to do is type "dir /a" to see the "hidden" files.


这篇关于无法使用C#隐藏通过cmd的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆