NAnt SDK Documentation - v0.92

DeleteTask Class

Deletes a file, fileset or directory.

For a list of all members of this type, see DeleteTask Members.

System.Object
   NAnt.Core.Element
      NAnt.Core.Task
         NAnt.Core.Tasks.DeleteTask

[Visual Basic]
<TaskName(Name:="delete")>
Public Class DeleteTask
    Inherits Task
[C#]
[TaskName(Name="delete")]
public class DeleteTask : Task

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

Deletes either a single file, all files in a specified directory and its sub-directories, or a set of files specified by one or more filesets.

If the File or Directory attribute is set then the fileset contents will be ignored. To delete the files in the fileset ommit the File and Directory attributes in the <delete> element.

If the specified file or directory does not exist, no error is reported.

Note    Read-only files cannot be deleted. Use the AttribTask first to remove the read-only attribute.

Example

Delete a single file.

    
<delete file="myfile.txt" />
    
  

Delete a directory and the contents within. If the directory does not exist, no error is reported.

    
<delete dir="${build.dir}" />
    
  

Delete a set of files.

    
<delete>
    <fileset>
        <include name="${basename}-??.exe" />
        <include name="${basename}-??.pdb" />
    </fileset>
</delete>
    
  

Requirements

Namespace: NAnt.Core.Tasks

Assembly: NAnt.Core (in NAnt.Core.dll)

See Also

DeleteTask Members | NAnt.Core.Tasks Namespace