c#怎样删除指定文件名的文件

时间:2021-07-19 14:16:38   收藏:0   阅读:26

 

技术分享图片

我有一个文件夹,里面有6个文件,我现在要删除字母B开头的三个文件,只需要剩下A开头的文件即可

用C#怎样操作???

 

foreach (string d in Directory.GetFileSystemEntries(文件夹路径))
{
if (File.Exists(d))
{
string me = Path.GetFileNameWithoutExtension(d);
if (me.StartsWith("B"))
{
File.Delete(d);
}}

 

原文:https://www.cnblogs.com/wufangmeng/p/15029751.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!