Delete a file

From CodeCodex

Implementations[edit]

C[edit]

 #include <stdio.h>
 int main()
 {
   remove("filename");
 
   return 0;
 }

Erlang[edit]

file:delete(Filename).

Java[edit]

    boolean success = (new File("filename")).delete();
    if (!success) {
        // Deletion failed
    }

OCaml[edit]

 Sys.remove "filename"

Perl[edit]

 unlink "filename";

PHP[edit]

  unlink($filename);

Python[edit]

import os
try: os.unlink('/path/to/file')
except OSError: pass # Deletion failed...

Ruby[edit]

File.delete('/path/to/file')