Delete a file: Difference between revisions
Content added Content deleted
m (→{{header|Fortran}}: +ifort) |
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
||
Line 89: | Line 89: | ||
=={{header|Axe}}== |
=={{header|Axe}}== |
||
<lang axe>DelVar "appvINPUT"</lang> |
<lang axe>DelVar "appvINPUT"</lang> |
||
=={{header|Batch File}}== |
|||
<lang dos>del input.txt |
|||
rd /s /q docs |
|||
del \input.txt |
|||
rd /s /q \docs</lang> |
|||
=={{header|BASIC}}== |
=={{header|BASIC}}== |
||
Line 158: | Line 151: | ||
190 CONTINUE |
190 CONTINUE |
||
200 END HANDLER</lang> |
200 END HANDLER</lang> |
||
=={{header|Batch File}}== |
|||
<lang dos>del input.txt |
|||
rd /s /q docs |
|||
del \input.txt |
|||
rd /s /q \docs</lang> |
|||
=={{header|C}}== |
=={{header|C}}== |
||
Line 180: | Line 180: | ||
rmdir("/docs"); |
rmdir("/docs"); |
||
return 0; |
return 0; |
||
}</lang> |
|||
=={{header|C++}}== |
|||
<lang cpp>#include <cstdio> |
|||
#include <direct.h> |
|||
int main() { |
|||
remove( "input.txt" ); |
|||
remove( "/input.txt" ); |
|||
_rmdir( "docs" ); |
|||
_rmdir( "/docs" ); |
|||
return 0; |
|||
}</lang> |
}</lang> |
||
Line 212: | Line 199: | ||
} |
} |
||
} |
} |
||
}</lang> |
|||
=={{header|C++}}== |
|||
<lang cpp>#include <cstdio> |
|||
#include <direct.h> |
|||
int main() { |
|||
remove( "input.txt" ); |
|||
remove( "/input.txt" ); |
|||
_rmdir( "docs" ); |
|||
_rmdir( "/docs" ); |
|||
return 0; |
|||
}</lang> |
}</lang> |
||
Line 431: | Line 431: | ||
print *, RemoveDirectory("\docs") |
print *, RemoveDirectory("\docs") |
||
end program</lang> |
end program</lang> |
||
=={{header|FreeBASIC}}== |
|||
<lang freebasic>' FB 1.05.0 Win64 |
|||
' delete file and empty sub-directory in current directory |
|||
Kill "input.txt" |
|||
RmDir "docs" |
|||
' delete file and empty sub-directory in root directory c:\ |
|||
' deleting file in root requires administrative privileges in Windows 10 |
|||
'Kill "c:\input.txt" |
|||
'RmDir "c:\docs" |
|||
Print "Press any key to quit" |
|||
Sleep |
|||
</lang> |
|||
=={{header|Free Pascal}}== |
=={{header|Free Pascal}}== |
||
Line 475: | Line 457: | ||
More convenient routines are <code>sysUtils.deleteFile</code> and <code>sysUtils.removeDir</code>. |
More convenient routines are <code>sysUtils.deleteFile</code> and <code>sysUtils.removeDir</code>. |
||
Both accept strings and just return, whether the operation was successful. |
Both accept strings and just return, whether the operation was successful. |
||
=={{header|FreeBASIC}}== |
|||
<lang freebasic>' FB 1.05.0 Win64 |
|||
' delete file and empty sub-directory in current directory |
|||
Kill "input.txt" |
|||
RmDir "docs" |
|||
' delete file and empty sub-directory in root directory c:\ |
|||
' deleting file in root requires administrative privileges in Windows 10 |
|||
'Kill "c:\input.txt" |
|||
'RmDir "c:\docs" |
|||
Print "Press any key to quit" |
|||
Sleep |
|||
</lang> |
|||
=={{header|Gambas}}== |
=={{header|Gambas}}== |
||
Line 548: | Line 548: | ||
OPEN (FILE="input.txt", "NEW") ! in current directory = C:\docs |
OPEN (FILE="input.txt", "NEW") ! in current directory = C:\docs |
||
WRITE(FIle="input.txt", DELETE=1)</lang> |
WRITE(FIle="input.txt", DELETE=1)</lang> |
||
=={{header|Icon}} and {{header|Unicon}}== |
|||
Icon supports 'remove' for files. |
|||
<lang Unicon>every dir := !["./","/"] do { |
|||
remove(f := dir || "input.txt") |stop("failure for file remove ",f) |
|||
rmdir(f := dir || "docs") |stop("failure for directory remove ",f) |
|||
} |
|||
</lang> |
|||
Note Icon and Unicon accept both / and \ for directory separators. |
|||
=={{header|Io}}== |
=={{header|Io}}== |
||
Line 561: | Line 570: | ||
File with("/input.txt") remove |
File with("/input.txt") remove |
||
Directory with("/docs") remove</lang> |
Directory with("/docs") remove</lang> |
||
=={{header|Icon}} and {{header|Unicon}}== |
|||
Icon supports 'remove' for files. |
|||
<lang Unicon>every dir := !["./","/"] do { |
|||
remove(f := dir || "input.txt") |stop("failure for file remove ",f) |
|||
rmdir(f := dir || "docs") |stop("failure for directory remove ",f) |
|||
} |
|||
</lang> |
|||
Note Icon and Unicon accept both / and \ for directory separators. |
|||
=={{header|J}}== |
=={{header|J}}== |
||
Line 699: | Line 699: | ||
{{libheader|LabVIEW_CWD}} |
{{libheader|LabVIEW_CWD}} |
||
{{VI solution|LabVIEW_Delete_a_file.png}} |
{{VI solution|LabVIEW_Delete_a_file.png}} |
||
=={{header|Lasso}}== |
=={{header|Lasso}}== |
||
Line 917: | Line 916: | ||
removeDir("docs") |
removeDir("docs") |
||
removeDir("/docs")</lang> |
removeDir("/docs")</lang> |
||
=={{header|Objective-C}}== |
|||
<lang objc>NSFileManager *fm = [NSFileManager defaultManager]; |
|||
// Pre-OS X 10.5 |
|||
[fm removeFileAtPath:@"input.txt" handler:nil]; |
|||
[fm removeFileAtPath:@"/input.txt" handler:nil]; |
|||
[fm removeFileAtPath:@"docs" handler:nil]; |
|||
[fm removeFileAtPath:@"/docs" handler:nil]; |
|||
// OS X 10.5+ |
|||
[fm removeItemAtPath:@"input.txt" error:NULL]; |
|||
[fm removeItemAtPath:@"/input.txt" error:NULL]; |
|||
[fm removeItemAtPath:@"docs" error:NULL]; |
|||
[fm removeItemAtPath:@"/docs" error:NULL];</lang> |
|||
=={{header|Objeck}}== |
=={{header|Objeck}}== |
||
Line 950: | Line 933: | ||
} |
} |
||
</lang> |
</lang> |
||
=={{header|Objective-C}}== |
|||
<lang objc>NSFileManager *fm = [NSFileManager defaultManager]; |
|||
// Pre-OS X 10.5 |
|||
[fm removeFileAtPath:@"input.txt" handler:nil]; |
|||
[fm removeFileAtPath:@"/input.txt" handler:nil]; |
|||
[fm removeFileAtPath:@"docs" handler:nil]; |
|||
[fm removeFileAtPath:@"/docs" handler:nil]; |
|||
// OS X 10.5+ |
|||
[fm removeItemAtPath:@"input.txt" error:NULL]; |
|||
[fm removeItemAtPath:@"/input.txt" error:NULL]; |
|||
[fm removeItemAtPath:@"docs" error:NULL]; |
|||
[fm removeItemAtPath:@"/docs" error:NULL];</lang> |
|||
=={{header|OCaml}}== |
=={{header|OCaml}}== |
||
Line 1,011: | Line 1,010: | ||
perl -e 'unlink "/input.txt"' |
perl -e 'unlink "/input.txt"' |
||
perl -e 'rmdir "/docs"' |
perl -e 'rmdir "/docs"' |
||
=={{header|Perl 6}}== |
|||
<lang perl6>unlink 'input.txt'; |
|||
unlink '/input.txt'; |
|||
rmdir 'docs'; |
|||
rmdir '/docs';</lang> |
|||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
Line 1,118: | Line 1,111: | ||
(delete-directory/files "docs")) |
(delete-directory/files "docs")) |
||
</lang> |
</lang> |
||
=={{header|Raku}}== |
|||
(formerly Perl 6) |
|||
<lang perl6>unlink 'input.txt'; |
|||
unlink '/input.txt'; |
|||
rmdir 'docs'; |
|||
rmdir '/docs';</lang> |
|||
=={{header|Raven}}== |
=={{header|Raven}}== |
||
Line 1,349: | Line 1,349: | ||
</lang> |
</lang> |
||
=={{header|Vedit macro language}}== |
|||
Vedit allows using either '\' or '/' as directory separator character, it is automatically converted to the one used by the operating system. |
|||
<lang vedit>// In current directory |
|||
File_Delete("input.txt", OK) |
|||
File_Rmdir("docs") |
|||
// In the root directory |
|||
File_Delete("/input.txt", OK) |
|||
File_Rmdir("/docs")</lang> |
|||
=={{header|VBA}}== |
=={{header|VBA}}== |
||
Line 1,396: | Line 1,386: | ||
</lang> |
</lang> |
||
=={{header|Vedit macro language}}== |
|||
Vedit allows using either '\' or '/' as directory separator character, it is automatically converted to the one used by the operating system. |
|||
<lang vedit>// In current directory |
|||
File_Delete("input.txt", OK) |
|||
File_Rmdir("docs") |
|||
// In the root directory |
|||
File_Delete("/input.txt", OK) |
|||
File_Rmdir("/docs")</lang> |
|||
=={{header|Visual Basic .NET}}== |
=={{header|Visual Basic .NET}}== |