# %unlink ()function

The %unlink() function removes the directory
entry named by the path name pointed to by path. The named file is
unlinked, and when all the links have been removed, and the file is
no longer open, the file is removed.

## Syntax

```
code = %unlink(path)
```
Upon successful completion, a value of 0 is returned.
Otherwise, a value of -1 is returned and system(0) is set to the value of errno.

## Example(s)

```
include dm,bp,unix.h fcntl.h
* Get a local file named myfile
fn=’myfile&#39;
fd=%creat(fn, o$rdwr)
...
* Remove the temporary file
if %unlink(fn) # 0 then
 crt ’Cannot remove temporary file. Error ’:system(0)
end
```

## See also

- [%close() function](https://d3codex.com/pickbasic-flashbasic/percent-close-function/)
- [%creat() function](https://d3codex.com/pickbasic-flashbasic/percent-creat-function/)
- [%open() function](https://d3codex.com/pickbasic-flashbasic/percent-open-function/)
- [FlashBASIC C functions overview](https://d3codex.com/pickbasic-flashbasic/flashbasic-c-functions-overview/)

---
Source: https://d3codex.com/pickbasic-flashbasic/percent-unlink-function/ - part of the D3Codex reference.
