# 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://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/hj5eoEd97JA2ktvxxND4/0.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://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/glwLRZDqhrQ8nB9Soz27/1.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.
