Difference between revisions of "Delete a file"

From CodeCodex

(Erlang)
(C)
 
(One intermediate revision by one other user not shown)
Line 5: Line 5:
 
<pre class="c">
 
<pre class="c">
 
  #include <stdio.h>
 
  #include <stdio.h>
  remove("filename");
+
  int main()
 +
{
 +
  remove("filename");
 +
 +
  return 0;
 +
}
 
</pre>
 
</pre>
  

Latest revision as of 21:32, 7 April 2011

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')