Delete a file: Difference between revisions

m
Line 412:
 
=={{header|Fortran}}==
=== Fortran 90 ===
{{works with|Fortran|90 and later}}
 
I don't know a way of deleting directories in Fortran
<lang fortran> OPEN (UNIT=5, FILE="input.txt", STATUS="OLD") ! Current directory
CLOSE (UNIT=5, STATUS="DELETE")
OPEN (UNIT=5, FILE="/input.txt", STATUS="OLD") ! Root directory
CLOSE (UNIT=5, STATUS="DELETE")</lang>
=== Intel Fortran on Windows ===
 
Use Intel Fortran bindings to the Win32 API. Here we are using the [https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-deletefilea DeleteFileA] and [https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-removedirectorya RemoveDirectoryA] functions.
 
<lang fortran>program DeleteFileExample
use kernel32
implicit none
print *, DeleteFile("input.txt")
print *, DeleteFile("\input.txt")
print *, RemoveDirectory("docs")
print *, RemoveDirectory("\docs")
end program</lang>
 
=={{header|FreeBASIC}}==
1,336

edits