SeeFiles:C#查看和修改文件或目录所有属性的工具
2012-09-25 16:17
447 查看
用C#写的一个可以查看和修改文件或目录所有属性的工具SeeFiles,某些情况下,我们会将一些文件设置为系统和隐藏属性,而不想让人看到。为什么不想?你懂得。
【网通】点击这里下载全部源程序 [b]【电信、网通】点击此处下载全部源程序[/b]
【下载说明】
1、单击上面这个地址,打开下载页面。
2、点普通下载--等待30秒--点“下载”按钮--保存
主要源程序:
【更多阅读】
[译]在C# .NET2.0实现单实例应用程序
[原]IniFile.cs:C#来操作ini配置文件
[原]使用Excel的VBA来读取和修改bmp位图像素数据
[译]C#控制计算机的并口LPT
[原]PjCleanSystemTrash:C#清除系统盘垃圾
[译]C#控制计算机的并口LPT
[原]WMICodeCreator:C#产生WMI代码的工具
[原]PjConvertImageFormat:用FreeImage.NET写的一个35种图像格式转换程序
[原]ManageStartUpApps:C#操作注册表来读取和修改开机启动项
[译]在C# .NET2.0实现单实例应用程序
【网通】点击这里下载全部源程序 [b]【电信、网通】点击此处下载全部源程序[/b]
【下载说明】
1、单击上面这个地址,打开下载页面。
2、点普通下载--等待30秒--点“下载”按钮--保存
主要源程序:
/* * Created by SharpDevelop. * User: PJ * Date: 2012-7-13 * Time: 10:35 * * To change this template use Tools | Options | Coding | Edit Standard Headers. */ using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using System.IO; using System.Diagnostics; namespace SeeFiles { /// <summary> /// Description of MainForm. /// </summary> public partial class MainForm : Form { private List<FileSystemInfo> file_system_info=null; public MainForm() { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); // // TODO: Add constructor code after the InitializeComponent() call. // } void RunDosCommand(string cmd) { Process p=new Process(); p.StartInfo.FileName="cmd.exe"; p.StartInfo.UseShellExecute=false; p.StartInfo.RedirectStandardInput=false; p.StartInfo.Arguments="/c "+cmd; p.StartInfo.RedirectStandardOutput=true; p.StartInfo.CreateNoWindow=true; p.Start(); p.WaitForExit(); p.Close(); } void BtnBrowserFolderClick(object sender, EventArgs e) { FolderBrowserDialog fbd=new FolderBrowserDialog(); fbd.ShowNewFolderButton = false; fbd.SelectedPath = Environment.CurrentDirectory; if(fbd.ShowDialog()==DialogResult.OK) { tbxFolder.Text=fbd.SelectedPath; listBox1.Items.Clear(); ListAll(fbd.SelectedPath); } } void ListAll(string path) { DirectoryInfo dirInfo = new DirectoryInfo(path); foreach(DirectoryInfo d in dirInfo.GetDirectories()) { listBox1.Items.Add(d.Name); } foreach(FileInfo f in dirInfo.GetFiles()) { listBox1.Items.Add(f.Name); } if(file_system_info==null) file_system_info=new List<FileSystemInfo>(); else file_system_info.Clear(); foreach(FileSystemInfo fsi in dirInfo.GetFileSystemInfos()) { file_system_info.Add(fsi); } } void ListBox1SelectedIndexChanged(object sender, EventArgs e) { int select_index = listBox1.SelectedIndex; FileSystemInfo fsi=this.file_system_info[select_index]; this.chkArchive.Checked = ((fsi.Attributes & FileAttributes.Archive)==FileAttributes.Archive) ? true : false; this.chkReadOnly.Checked = ((fsi.Attributes & FileAttributes.ReadOnly)==FileAttributes.ReadOnly) ? true : false; this.chkSystem.Checked = ((fsi.Attributes & FileAttributes.System)==FileAttributes.System) ? true : false; this.chkHidden.Checked = ((fsi.Attributes & FileAttributes.Hidden)==FileAttributes.Hidden) ? true : false; this.chkDirectory.Checked = ((fsi.Attributes & FileAttributes.Directory)==FileAttributes.Directory) ? true : false; this.chkTemporary.Checked = ((fsi.Attributes & FileAttributes.Temporary)==FileAttributes.Temporary) ? true : false; this.chkOffline.Checked = ((fsi.Attributes & FileAttributes.Offline)==FileAttributes.Offline) ? true : false; this.chkDevice.Checked = ((fsi.Attributes & FileAttributes.Device)==FileAttributes.Device) ? true : false; this.chkNormal.Checked = ((fsi.Attributes & FileAttributes.Normal)==FileAttributes.Normal) ? true : false; this.chkCompressed.Checked = ((fsi.Attributes & FileAttributes.Compressed)==FileAttributes.Compressed) ? true : false; this.chkSparseFile.Checked = ((fsi.Attributes & FileAttributes.SparseFile)==FileAttributes.SparseFile) ? true : false; this.chkReparsePoint.Checked = ((fsi.Attributes & FileAttributes.ReparsePoint)==FileAttributes.ReparsePoint) ? true : false; this.chkEncrypted.Checked = ((fsi.Attributes & FileAttributes.Encrypted)==FileAttributes.Encrypted) ? true : false; this.chkNotContentIndexed.Checked = ((fsi.Attributes & FileAttributes.NotContentIndexed)==FileAttributes.NotContentIndexed) ? true : false; } void ChkSystemMouseClick(object sender, MouseEventArgs e) { ChangeAttribute(sender); } void ChangeAttribute(object sender) { CheckBox chkbox = (CheckBox)sender; int select_index = listBox1.SelectedIndex; FileSystemInfo fsi=this.file_system_info[select_index]; FileAttributes temp; switch(int.Parse(chkbox.Tag.ToString())) { case 1: temp = FileAttributes.ReadOnly; break; case 2: temp = FileAttributes.Hidden; break; case 4: temp = FileAttributes.System; break; case 16: temp = FileAttributes.Directory; break; case 32: temp = FileAttributes.Archive; break; case 64: temp = FileAttributes.Device; break; case 128: temp = FileAttributes.Normal; break; case 256: temp = FileAttributes.Temporary; break; case 512: temp = FileAttributes.SparseFile; break; case 1024: temp = FileAttributes.ReparsePoint; break; case 2048: temp = FileAttributes.Compressed; break; case 4096: temp = FileAttributes.Offline; break; case 8192: temp = FileAttributes.NotContentIndexed; break; case 16384: temp = FileAttributes.Encrypted; break; default: temp = FileAttributes.Normal; break; } if(chkbox.Checked) fsi.Attributes = fsi.Attributes | temp; else fsi.Attributes = fsi.Attributes & ~temp; } void ChkHiddenMouseClick(object sender, MouseEventArgs e) { ChangeAttribute(sender); } void ChkReadOnlyMouseClick(object sender, MouseEventArgs e) { ChangeAttribute(sender); } void ChkArchiveMouseClick(object sender, MouseEventArgs e) { ChangeAttribute(sender); } void ChkDirectoryMouseClick(object sender, MouseEventArgs e) { ChangeAttribute(sender); } void ChkTemporaryMouseClick(object sender, MouseEventArgs e) { ChangeAttribute(sender); } void ChkOfflineMouseClick(object sender, MouseEventArgs e) { ChangeAttribute(sender); } void ChkNormalMouseClick(object sender, MouseEventArgs e) { ChangeAttribute(sender); } void ChkDeviceMouseClick(object sender, MouseEventArgs e) { ChangeAttribute(sender); } void ChkCompressedMouseClick(object sender, MouseEventArgs e) { ChangeAttribute(sender); } void ChkSparseFileMouseClick(object sender, MouseEventArgs e) { ChangeAttribute(sender); } void ChkReparsePointMouseClick(object sender, MouseEventArgs e) { ChangeAttribute(sender); } void ChkEncryptedMouseClick(object sender, MouseEventArgs e) { ChangeAttribute(sender); } void ChkNotContentIndexedMouseClick(object sender, MouseEventArgs e) { ChangeAttribute(sender); } void BtnOpenClick(object sender, EventArgs e) { if( this.listBox1.SelectedItem.ToString() != "" ) { this.RunDosCommand("start \"\" \""+this.tbxFolder.Text.ToString()+"\\"+this.listBox1.SelectedItem.ToString()+"\""); } } } }
【更多阅读】
[译]在C# .NET2.0实现单实例应用程序
[原]IniFile.cs:C#来操作ini配置文件
[原]使用Excel的VBA来读取和修改bmp位图像素数据
[译]C#控制计算机的并口LPT
[原]PjCleanSystemTrash:C#清除系统盘垃圾
[译]C#控制计算机的并口LPT
[原]WMICodeCreator:C#产生WMI代码的工具
[原]PjConvertImageFormat:用FreeImage.NET写的一个35种图像格式转换程序
[原]ManageStartUpApps:C#操作注册表来读取和修改开机启动项
[译]在C# .NET2.0实现单实例应用程序
相关文章推荐
- C#文件操作,父目录,子目录,所有文件、文件夹,属性信息
- C#实现修改目录文件下所有子文件的名称---按规律重命名
- 一个批量修改文件属性的工具
- C#直接删除指定目录下的所有文件及文件夹(保留目录)
- C# 查看目录文件及文件大小
- 将指定目录的所有文件及文件夹copy到指定目录下,只copy 7天内创建的或是7天内修改过的
- 用C#列出指定目录下的所有指定扩展名(多个扩展名)的文件
- 菜鸟Linux攻略--目录文件权限的查看和修改(详细)
- 进入%WINDIR%/FONTS目录,选中所有文件,右键点选属性,看看结果是什么?
- C# SHMultiFileProperties查看多个文件属性
- Linux文件和目录的操作(十) 查看属性 stat
- 菜鸟Linux攻略--目录文件权限的查看和修改(详细)
- C#取得指定路径下所有目录及文件名称(可递归)
- 如何查看Linux下面某一个目录下所有的隐藏文件和文件夹
- C# 获取指定目录下所有文件信息、移动目录、拷贝目录
- C#实现把指定文件夹下的所有文件复制到指定路径下以及修改指定文件的后缀名
- 文件属性查看、所有人所有组管理,普通权限,特殊权限,访问控制,默认权限
- C# 文件操作(全部) 追加、拷贝、删除、移动文件、创建目录 修改文件名、文件夹名
- python写一段脚本代码自动完成输入(目录下的所有)文件的数据替换(修改数据和替换数据都是输入的)
- C#.NET中遍历指定目录下的文件(及所有子目录及子目录里更深层目录里的文件)