delegate void AddListViewItemsCallBack(ListViewItem[] lvis);
private void addListViewItem(ListViewItem[] lvis)
{
if (listView1.InvokeRequired)
{
AddListViewItemsCallBack d = new AddListViewItemsCallBack(addListViewItem);
this.Invoke(d, new object[] { lvis });
}
else
{
listView1.Items.AddRange(lvis);
}
}
private void clearfile(object pp)
{
Parameter p = (Parameter)pp;
string pathvariable=p.Path;
string fileexpand=p.SearchPattern;
string filetype=p.FileType;
string pathadd = p.PathAdd;
//如果小的目录,不用多线程,注意下面的改动,不把listView.Refresh()放在循环中即可消除闪烁。
string path = Environment.GetEnvironmentVariable(pathvariable) + pathadd;
string[] pathfiles = Directory.GetFiles(path, fileexpand, SearchOption.AllDirectories);
ListViewItem[] lvis = new ListViewItem[pathfiles.Length];
if ((pathfiles.Length) > 0)
{
int i = 0;
foreach (string filedir in pathfiles)
{
string filename = filedir.Substring(filedir.LastIndexOf("\\") + 1);
FileInfo filelg = new FileInfo(filedir);
string filelength = (filelg.Length / 1024).ToString();
if (filelength == "0") filelength = "1";
ListViewItem objListItem = new ListViewItem(filetype);
objListItem.SubItems.Add(filename);
objListItem.SubItems.Add(filelength);
objListItem.SubItems.Add(filedir);
objListItem.EnsureVisible();
lvis[i++]=objListItem;
}
}
addListViewItem(lvis);
//若不使用多线程,调用此句listView1.Items.AddRange(lvis);
}
private void button1_Click(object sender, EventArgs e)
{
listView1.Items.Clear();
Thread th =new Thread(new ParameterizedThreadStart(this.clearfile));
Parameter p=new Parameter();
p.Path="temp";
p.SearchPattern="*.*";
p.FileType="临时文件";
p.PathAdd="";
th.Start(p);
}
没有合适的资源?快使用搜索试试~ 我知道了~
C# 系统垃圾扫描程序
共49个文件
cs:7个
application:6个
manifest:6个
5星 · 超过95%的资源 需积分: 10 16 下载量 43 浏览量
2008-09-12
15:52:56
上传
评论
收藏 370KB RAR 举报
温馨提示
解决了LISTVIEW刷新时闪烁的问题,只写了几个位置的扫描,大家可以自己添加!
资源推荐
资源详情
资源评论
收起资源包目录
scan.rar (49个子文件)
scan
scan.sln 905B
scan
Form1.cs 8KB
bin
Debug
IrisSkin2.dll 504KB
scan.pdb 32KB
scan.vshost.application 1KB
DiamondBlue.ssk 16KB
scan.application 1KB
DeepGreen.ssk 5KB
scan.exe 24KB
scan.exe.manifest 3KB
scan.vshost.exe.manifest 3KB
scan.vshost.exe 6KB
Release
scan.pdb 22KB
scan.application 1KB
scan.publish
scan_1_0_0_1
scan.exe.deploy 20KB
scan.exe.manifest 6KB
scan.application 5KB
setup.exe 414KB
scan.exe 20KB
scan.exe.manifest 2KB
scan.csproj 5KB
obj
Debug
scan.csproj.GenerateResource.Cache 842B
scan.Properties.Resources.resources 180B
scan.pdb 32KB
scan.application 1KB
ResolveAssemblyReference.cache 6KB
scan.Form1.resources 180B
scan.exe 24KB
Refactor
scan.exe.manifest 3KB
TempPE
Release
scan.csproj.GenerateResource.Cache 842B
scan.Properties.Resources.resources 180B
scan.pdb 22KB
scan.application 1KB
scan.Form1.resources 180B
scan.exe 20KB
scan.exe.manifest 2KB
TempPE
scan.csproj.FileList.txt 771B
Properties
Resources.Designer.cs 3KB
Settings.settings 249B
Resources.resx 5KB
Settings.Designer.cs 1KB
AssemblyInfo.cs 1KB
Program.cs 463B
DoubleBufferListView.cs 441B
scan.csproj.user 580B
Form1.Designer.cs 6KB
Form1.resx 6KB
help.txt 2KB
scan.suo 19KB
共 49 条
- 1
资源评论
- 12595649362013-04-26略显复杂,代码值得研究研究
- qnlyphqy2013-05-19这个程序好棒 就是点击清理垃圾时候没有什么反映 而且那个listbox有些闪烁 最好重写重绘窗体的函数
- ndnnzhf2016-09-01代码写的不错啊
q5331006
- 粉丝: 0
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- video_20240425_124410_edit.mp4
- IMG_20240425_120538.jpg
- My Complete Genome_6k Base-Pairs of Phenotype SNPs_Complete Raw Data.zip
- qt 的mqtt测试demo
- 移动应用开发教程-zip.zip
- mosquitto-2.018-install-windows-x64
- FTPServer FTP 服务器,绿色免安装,单文件
- 梦畅语音点名软件,上课点名
- 利用ADNI数据集和标签,在tensorflow框架上使用tensorlayer接口,通过架构u-net实现海马体的分割
- Kutools for Word v9.0 office word 插件
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功