删除所有带有“模式”的文件 [英] Delete all files with "a pattern"

查看:107
本文介绍了删除所有带有“模式”的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我想从目录中删除所有匹配的文件:bar *。*

我知道我可以做例如:system(del bar *。*),但这将是

调出命令提示符窗口,因为我的应用程序是一个winmain应用程序这个

不会很好。我可以使用DeleteFile,但你不能在这个中使用通配符




我怎么能用Windows函数做到这一点?


在此先感谢,

Viv

Hi all,

I would like to delete from a directory all the files that match: bar*.*
I know that I could do for instance: system("del bar*.*"), but this will
bring up the command prompt window and as my app is a winmain app this
wouldn''t be nice. I could use DeleteFile, but you can not use wildcards
in this one.

How could I do this using Windows functions?

Thanks in advance,
Viv

推荐答案

您好,


您可以使用SHFileOperation和SHFileOperation。使用FO_DELETE标志设置在

SHFILEOPSTRUCT结构中,或使用PathMatchSpec浏览删除与表达式匹配的文件的目录。功能。


问候,

Arno


" Viviana Vc" < VC ******* @ hotmail.com>一个écritdansle message de

新闻:2g ************ @ uni-berlin.de ...
Hello,

You can either use "SHFileOperation" with FO_DELETE flag set in the
SHFILEOPSTRUCT structure or browse the directory deleting files that match
your expression using "PathMatchSpec" function.

Regards,
Arno

"Viviana Vc" <vc*******@hotmail.com> a écrit dans le message de
news:2g************@uni-berlin.de...
大家好,

我想从目录中删除所有匹配的文件:bar *。*
我知道我可以做的例如:system(" del bar *。*") ,但是这将打开命令提示窗口,因为我的应用程序是一个winmain应用程序,这不会很好。我可以使用DeleteFile,但你不能在这个中使用通配符。

我怎么能用Windows功能呢?

提前谢谢,
Viv
Hi all,

I would like to delete from a directory all the files that match: bar*.*
I know that I could do for instance: system("del bar*.*"), but this will
bring up the command prompt window and as my app is a winmain app this
wouldn''t be nice. I could use DeleteFile, but you can not use wildcards
in this one.

How could I do this using Windows functions?

Thanks in advance,
Viv



您好,Viviana


查看Directory.GetFiles方法。您可以使用

掩码获取文件列表,然后使用标准File.Delete方法删除它们。


HTH

Alex


" Viviana Vc" < VC ******* @ hotmail.com>在消息中写道

新闻:2g ************ @ uni-berlin.de ...
Hi, Viviana

Have a look at Directory.GetFiles method. You can get list of files using
mask and then delete them using standard File.Delete method.

HTH
Alex

"Viviana Vc" <vc*******@hotmail.com> wrote in message
news:2g************@uni-berlin.de...
大家好,

我想从目录中删除所有匹配的文件:bar *。*
我知道我可以做的例如:system(" del bar *。*"),但是这个将
调出命令提示符窗口,因为我的应用程序是一个winmain应用程序,这将不会很好。我可以使用DeleteFile,但你不能在这个中使用通配符。

我怎么能用Windows功能呢?

提前谢谢,
Viv
Hi all,

I would like to delete from a directory all the files that match: bar*.*
I know that I could do for instance: system("del bar*.*"), but this will
bring up the command prompt window and as my app is a winmain app this
wouldn''t be nice. I could use DeleteFile, but you can not use wildcards
in this one.

How could I do this using Windows functions?

Thanks in advance,
Viv





" Viviana Vc" < VC ******* @ hotmail.com>在消息中写道

新闻:2g ************ @ uni-berlin.de ...

"Viviana Vc" <vc*******@hotmail.com> wrote in message
news:2g************@uni-berlin.de...
大家好,

我想从目录中删除所有匹配的文件:bar *。*
我知道我可以做的例如:system(" del bar *。*"),但是这个将
调出命令提示符窗口,因为我的应用程序是一个winmain应用程序,这将不会很好。我可以使用DeleteFile,但是你不能在这个中使用通配符。

我怎么能用Windows函数做这个?
Hi all,

I would like to delete from a directory all the files that match: bar*.*
I know that I could do for instance: system("del bar*.*"), but this will
bring up the command prompt window and as my app is a winmain app this
wouldn''t be nice. I could use DeleteFile, but you can not use wildcards
in this one.

How could I do this using Windows functions?




使用FindFirstFile()和它的兄弟姐妹获取文件名,然后

DeleteFile()。


- Sten



Use FindFirstFile() and it''s siblings to get the file names and then
DeleteFile().

- Sten


这篇关于删除所有带有“模式”的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆