Delete a file: Difference between revisions
Content added Content deleted
m (→{{header|Fortran}}: +ifort) |
|||
Line 412: | Line 412: | ||
=={{header|Fortran}}== |
=={{header|Fortran}}== |
||
=== Fortran 90 === |
|||
{{works with|Fortran|90 and later}} |
{{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 |
<lang fortran> OPEN (UNIT=5, FILE="input.txt", STATUS="OLD") ! Current directory |
||
CLOSE (UNIT=5, STATUS="DELETE") |
CLOSE (UNIT=5, STATUS="DELETE") |
||
OPEN (UNIT=5, FILE="/input.txt", STATUS="OLD") ! Root directory |
OPEN (UNIT=5, FILE="/input.txt", STATUS="OLD") ! Root directory |
||
CLOSE (UNIT=5, STATUS="DELETE")</lang> |
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}}== |
=={{header|FreeBASIC}}== |