FileDeleteMultipleStep Execute not doing anything

May 22, 2009 at 10:51 AM

I was using the FileDeleteMultipleStep but the files weren't being deleted ...

stepped through the source code and the call goes to ...

  public void Execute(XmlNode testConfig, Context context)
  {
   this.directory = context.ReadConfigAsString( testConfig, "Directory" );
   this.searchPattern = context.ReadConfigAsString( testConfig, "SearchPattern" );
  }

Am I missing something, this doesn't seem to do any deletion ?

Whereas the other Execute does ...

     public void Execute(Context context)
     {
            DirectoryInfo di = new DirectoryInfo(this.directory);
            FileInfo[] files = di.GetFiles(this.searchPattern);

            context.LogInfo("{0} files were found matching the File Mask: \"{1}\" in the directory: \"{2}\"", files.Length, this.searchPattern, this.directory);

            // Count all the files in each subdirectory that contain the letter "e."
            foreach (FileInfo file in files)
            {
                File.Delete(file.FullName);
                context.LogInfo("File: \"{0}\" was successfully deleted.", file.FullName);
            }
        }

May 22, 2009 at 11:16 AM

Steve

Yes, this is a bug in the code. We had to fix this manually at my workplace too :-)

Since you have the source, in the first Execute() method which takes the testConfig and context, put in a line to call the overloaded Execute(context) method, at the end , after the member variables are assigned.

HTH,

Benjy

May 22, 2009 at 1:21 PM

Gotya ... that works a treat

Thanks again Benjy

 

Cheers,

SteveC.

Coordinator
May 25, 2009 at 8:28 PM

Hi,

I'lm a little behind on bug fixes, I'll have a blast through and get a new release out.

 

thanks for raising this

 

Kevin

Coordinator
Jun 5, 2009 at 7:37 PM

This fix is going into v3.1, thanks

 

Kevin