chilkat-如何使用Chilkat.FileAccess.FileDelete函数使用*。*删除所有文件

时间:2018-11-24 17:09:48

标签: chilkat

我有问题要使用Chilkat.FileAccess.FileDelete使用删除所有文件。,日志显示以下内容,如何处理该问题,谢谢!

ChilkatLog:   FileDelete:     Chilkat版本:9.5.0.75     WindowsError:文件名,目录名称或卷标签语法不正确。     failedToDeleteFilepath:C:\ TMP \ untar001 *。*   --FileDelete --ChilkatLog

2 个答案:

答案 0 :(得分:0)

您可以使用Chilkat枚举目录中的文件,或枚举整个目录树中的文件。

在此处查看DirTree类:http://www.chilkatsoft.com/refdoc/csDirTreeRef.html

和此处的示例:https://www.example-code.com/csharp/dirTree_iterate.asp

答案 1 :(得分:-1)

您正在将通配符传递到FileAccess.FileDelete,后者不接受通配符。不幸的是,Chilkat API没有提供枚举目录中文件的方法,因此,如果您要坚持使用Chilkat API,则必须删除整个目录:

fa.DirDelete("C:\\TMP");

否则,使用标准.NET:

foreach (string file in Directory.EnumerateFiles(
    "C:\\TMP", 
    "untar001*.*" , 
    SearchOption.AllDirectories) 
    )
{
    fa.FileDelete(file);
}
相关问题