# DeleteFile (String filePath)

| **Name**    | ***DeleteFile***                                   |
| ----------- | -------------------------------------------------- |
| Syntax      | DeleteFile (String filePath)                       |
| Purpose     | To delete a file if it exists.                     |
| Description | Deletes a file if exists.                          |
| Return Type | Void                                               |
| Parameter   | filePath \[System.String] – Full path of the file. |

![](https://github.com/astera-software/Astera_Data_Stack_v9/blob/main/.gitbook/assets/0%20\(187\).png)

**Example**

In this example, we are passing the required parameter to the function transformation object using a *Variables* object. We will be deleting a “Test.txt” source file which exists within a folder.

Where,

*filePath* = *C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\Functions Documentation\Files\DeleteFile\Test.txt*

![](https://github.com/astera-software/Astera_Data_Stack_v9/blob/main/.gitbook/assets/1%20\(187\).png)

Right-click on the function transformation object and select *Preview Output.* While the *Data Preview* will not generate an output, the existing file within the specified location will be deleted.
