判断是否下载指定客户端(遍历硬盘上的全部文件文件夹)
2015-05-09 15:10
309 查看
public void GetAllFiles(string fpath, string filetype)
{
//System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(fpath); // 遍历指定文件类型的文件
//System.IO.FileInfo[] fs = dir.GetFiles("*" + filetype);
//foreach (System.IO.FileInfo f in fs)
//{
// if (f.Name == "Client.exe")
// {
// res = true;
// finame = f.FullName;
// Label1.Text = finame;
// }
//}
foreach (string f in Directory.GetDirectories(fpath)) // 遍历指定文件夹类型的文件夹
{
DirectoryInfo di = new DirectoryInfo(@f);
if (!IsSystemHidden(di))
{
if (f.IndexOf("Documents and Settings") < 0)
{
if (f.IndexOf("英雄联盟") > 0)
{
string file1 = (f + "\\TCLS\\BackgroundDownloader.exe");
string file2 = (f + "\\TCLS\\Client.exe");
if (File.Exists(file1) && File.Exists(file2))
{
Label1.Text = file2;
}
}
else
{
GetAllFiles(f, filetype);
}
}
}
}
}
private bool IsSystemHidden(DirectoryInfo dirInfo)
{
if (dirInfo.Parent == null)
{
return false;
}
string attributes = dirInfo.Attributes.ToString();
if (attributes.IndexOf("Hidden") > -1 && attributes.IndexOf("System") > -1)
{
return true;
}
return false;
}
protected void Button1_Click(object sender, EventArgs e)
{
DriveInfo[] allDrives = DriveInfo.GetDrives();
for (int i = allDrives.Length - 1; i >= 0; i--)
{
if (allDrives[i].Name != "C:\\")
{
if (allDrives[i].DriveType.ToString() == "Fixed")
{
GetAllFiles(allDrives[i].Name, "exe"); //自动寻找目录、
}
}
}
}
{
//System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(fpath); // 遍历指定文件类型的文件
//System.IO.FileInfo[] fs = dir.GetFiles("*" + filetype);
//foreach (System.IO.FileInfo f in fs)
//{
// if (f.Name == "Client.exe")
// {
// res = true;
// finame = f.FullName;
// Label1.Text = finame;
// }
//}
foreach (string f in Directory.GetDirectories(fpath)) // 遍历指定文件夹类型的文件夹
{
DirectoryInfo di = new DirectoryInfo(@f);
if (!IsSystemHidden(di))
{
if (f.IndexOf("Documents and Settings") < 0)
{
if (f.IndexOf("英雄联盟") > 0)
{
string file1 = (f + "\\TCLS\\BackgroundDownloader.exe");
string file2 = (f + "\\TCLS\\Client.exe");
if (File.Exists(file1) && File.Exists(file2))
{
Label1.Text = file2;
}
}
else
{
GetAllFiles(f, filetype);
}
}
}
}
}
private bool IsSystemHidden(DirectoryInfo dirInfo)
{
if (dirInfo.Parent == null)
{
return false;
}
string attributes = dirInfo.Attributes.ToString();
if (attributes.IndexOf("Hidden") > -1 && attributes.IndexOf("System") > -1)
{
return true;
}
return false;
}
protected void Button1_Click(object sender, EventArgs e)
{
DriveInfo[] allDrives = DriveInfo.GetDrives();
for (int i = allDrives.Length - 1; i >= 0; i--)
{
if (allDrives[i].Name != "C:\\")
{
if (allDrives[i].DriveType.ToString() == "Fixed")
{
GetAllFiles(allDrives[i].Name, "exe"); //自动寻找目录、
}
}
}
}
相关文章推荐
- c++判断硬盘是否连接、修改指定盘符、读取配置文件、获取exe路径
- 在指定路径创建文件夹,读取图片文件,缩放图片,判断文件夹是否存在,
- 判断所指定的文件或目录(文件夹)是否存在存储过程
- Delphi判断文件夹下子文件夹是否为空,及删除子文件夹,遍历文件夹及子文件夹的文件
- MFC判断指定路径下目标文件、目标文件夹是否存在
- 如何将服务器端文件 自动下载并保存到客户端IE临时文件夹 或者指定文件夹
- 用VBA判断指定的文件夹或文件是否存在
- 用DirectoryExists和FileExists判断指定路径下是否存在指定的文件夹或文件
- VBA判断指定的文件夹或文件是否存在
- ios判断程序文件夹下是否存在指定文件
- C++遍历文件夹及判断某一文件或目录是否存在
- C#获取FTP目录下文件夹、文件的方法,进而判断FTP下指定文件夹是否存在
- 读取指定文件夹里面的所有图片取出里面其中一张图片和判断文件夹或文件是否存在
- asp.net 判断指定路径指定文件夹下是否有图片文件存在
- Java遍历文件夹&判断是否存在某一类型的文件
- c++判断文件或文件夹是否存在--转载
- 如何在tiptop 4GL程序中判断客户端机器某个文件是否存在
- 用TreeView控件实现资源管理器(显示本地硬盘下所有文件夹和文件,并可以浏览图片)(示例代码下载)
- C#遍历指定文件夹中的所有文件(转)
- Java 判断文件夹、文件是否存在、否则创建文件夹