0

I have the problem to use Chilkat.FileAccess.FileDelete to delete all file using ., the log says the following, how to handle the problem, thanks!

ChilkatLog: FileDelete: ChilkatVersion: 9.5.0.75 WindowsError: The filename, directory name, or volume label syntax is incorrect. failedToDeleteFilepath: C:\TMP\untar001*.* --FileDelete --ChilkatLog

maxking
  • 3
  • 1

2 Answers2

0

You can use Chilkat to enumerate files in a directory, or enumerate files in an entire directory tree.

See the DirTree class here: http://www.chilkatsoft.com/refdoc/csDirTreeRef.html

and an example here: https://www.example-code.com/csharp/dirTree_iterate.asp

Chilkat Software
  • 1,405
  • 1
  • 9
  • 8
-1

You are passing wildcards to FileAccess.FileDelete, which doesn't accept wildcards. Unfortunately the Chilkat API doesn't provide means to enumerate files in a directory, so if you want to stick to the Chilkat API you would have to delete the entire directory:

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

Otherwise, using standard .NET:

foreach (string file in Directory.EnumerateFiles(
    "C:\\TMP", 
    "untar001*.*" , 
    SearchOption.AllDirectories) 
    )
{
    fa.FileDelete(file);
}
mnistic
  • 10,866
  • 2
  • 19
  • 33