基本信息
源码名称:C# 检索文件目录下所有文件,加载至Richtxt
源码大小:0.83M
文件格式:.zip
开发语言:C#
更新时间:2017-04-18
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍

    这个软件可以设置开机启动、窗体置顶、隐藏鼠标、全屏、获取目录文件、重启软件功能。


private void WriteRegistry()
{
string strName = Application.ExecutablePath;
if (File.Exists(strName))
{
 string strNewName = Path.GetFileName(strName);
 RegistryKey reg = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
 if (reg == null)
 {
  reg = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
 }
 else
 {
  if (reg.GetValue(strNewName) == null)
  {
   reg.SetValue(strNewName, strName);
  }
 }
}
}
void Ckbox_autorunCheckedChanged(object sender, EventArgs e)
{
if(ckbox_autorun.Checked==true)
WriteRegistry();
else
{

}
}
void Ckbox_topCheckedChanged(object sender, EventArgs e)
{ if(ckbox_top.Checked==true)
TopMost=true;//窗体置顶
else
TopMost=false;//取消窗体置顶
}
void CkBox_cursorCheckedChanged(object sender, EventArgs e)
{
if(ckBox_cursor.Checked==true)
Cursor.Hide();//=true;//窗体置顶
else
Cursor.Show();
}
void Rdo_allScreenCheckedChanged(object sender, EventArgs e)
{
if(rdo_allScreen.Checked==true)
{
rdo_default.Checked=false;
this.FormBorderStyle = FormBorderStyle.None;//设置窗体为无边框样式
            this.WindowState = FormWindowState.Maximized;//最大化显示窗体

}else
{
rdo_allScreen.Checked=false;
rdo_default.Checked=true;
this.FormBorderStyle = FormBorderStyle.Sizable;//设置窗体为有边框样式
            this.WindowState = FormWindowState.Normal;//正常显示窗体
}
}

        List<string> strfile = new List<string>();
        /// <summary>
        /// 递归获取文件
        /// </summary>
        /// <param name="path">文件目录</param>
        private void searchFile(string path)
        {
            try
            {
                //获得当前目录下的所有文件
                string[] files = Directory.GetFiles(path, "*.*");
                foreach (string f in files)
                {
                    //写入文件
                    strfile.Add(f);
                }
                //获得当前目录下的所有目录
                string[] dirs = Directory.GetDirectories(path);
                foreach (string dir in dirs)
                {
                    searchFile(dir);
                }
            }
            catch { }
        }


        private void button1_Click(object sender, EventArgs e)
        {
            progressBar.Value = 0;
            string path = @"d:\media";
            if (textBox1.Text != "")
            {
                path = textBox1.Text;
            }
            
            searchFile(path);
            progressBar.Maximum = strfile.Count;
            for (int i = 0; i < strfile.Count; i )
            {
                richTextBox1.Text = (strfile[i].ToString() "\r\n");
                progressBar.Value ;
                Text = i.ToString();
            }
            MessageBox.Show("读取完毕!");

        }

        private void button2_Click(object sender, EventArgs e)
        {
            Application.Restart();
        }