zoukankan      html  css  js  c++  java
  • 伪装文件夹

    实现效果:

      

    知识运用:  

      File类的CreateText方法    //创建或打开一个文件用于写入UTF-8编码的文本

      public static StreamWriter CreateText (string path)    //f返回一个StreamWriter对象 它使用UTF-8编码写入指定文件

      StreamWriter对象的WriteLine方法  //将字符串写入文本流

      public virtual voidWriteLine (string value)

    实现代码:

            //返回对应值
            private string GetFolType()
            {
                int flage = comboBox1.SelectedIndex;
                switch (flage)
                { 
                    case 0:return @"{20D04FE0-3AEA-1069-A2D8-08002B30309D}";
                    case 1:return @"{450D8FBA-AD25-11D0-98A8-0800361B1103}";
                    case 2:return @"{992CFFA0-F557-101A-88EC-00DD010CCC48}";
                    case 3:return @"{21EC2020-3AEA-1069-A2DD-08002B30309D}"; 
                    case 4:return @"{D6277990-4C6A-11CF-8D87-00AA0060F5BF}";
                    case 5:return @"{2227A280-3AEA-1069-A2DE-08002B30309D}";
                    case 6:return @"{208D2C60-3AEA-1069-A2D7-08002B30309D}";
                    case 7:return @"{645FF040-5081-101B-9F08-00AA002F954E}";
                    case 8:return @"{85BBD920-42A0-1069-A2E4-08002B30309D}"; 
                    case 9:return @"{BD84B380-8CA2-1069-AB1D-08000948F534}";
                }
                return @"{20D04FE0-3AEA-1069-A2D8-08002B30309D}";
            }
            //进行伪装操作
            private void Camouflage(string fpath)
            {
                if (File.Exists(fpath + "\" + @"desktop.ini"))
                    File.Delete(fpath + "\" + @"desktop.ini");
                StreamWriter sw= File.CreateText(fpath+"\"+@"desktop.ini");
                sw.WriteLine(@"[.ShellClassInfo]");
                sw.WriteLine("CLSID="+GetFolType());
                sw.Close();
                File.SetAttributes(fpath + "\" + @"desktop.ini",FileAttributes.Hidden);
                File.SetAttributes(fpath + "\" + @"desktop.ini", FileAttributes.System);
                MessageBox.Show("伪装成功","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
            }
            //还原伪装文件夹
            private void NCamouflage(string fpath)
            {
                string temp = fpath + "\" + @"desktop.ini";
                if (!File.Exists(temp))
                {
                    MessageBox.Show("该文件夹没有被伪装", "提示");
                    return;
                }
                else
                {
                    File.Delete(temp);
                    MessageBox.Show("还原成功!", "提示");
                }
            }
    

      

  • 相关阅读:
    HBase导入数据同时与Phoenix实现同步映射
    Hive导入数据到HBase,再与Phoenix映射同步
    CDH5.16.1离线集成Phoenix
    设计原则学习笔记
    Maven安装配置
    SpringBoot之Mybatis操作中使用Redis做缓存
    Linux服务器防火墙白名单设置
    Linux查看端口占用情况,并强制释放占用的端口
    shell脚本切割tomcat日志文件
    mysql读写分离
  • 原文地址:https://www.cnblogs.com/feiyucha/p/10249399.html
Copyright © 2011-2022 走看看