e r l a n g : c o o k b o o k

/ Erlang.FileDeletingAFile

This Web


WebHome 
WebChanges 
TOC
NewRecipe 
WebTopicList 
WebStatistics 

All Webs


Chicken
Cookbook
Erlang
Know
Main
Plugins
Sandbox
Scm
TWiki  

Erlang Links


Erlang.org
Erlang Wiki
ErlMan
Erlang Wiki
The Jungerl
Erlang-fr.org
Joe Armstrong
Lambda the Ultimate

Erlang Web Ring


[Prev]: Joe Armstrong's Page
[Next]: Joe Armstrong's Page

Deleting a File

Problem

You want to delete a file.

Solution

Use Erlang's standard function file:delete.

1> file:delete("/this/file/will/soon/be/gone.txt").
ok

The function deletes the file with the given pathname, if it exists, returning ok if a file was deleted successfully, otherwise an error is returned.

Discussion

Note that if you wish to delete a directory, you should use the corresponding function file:del_dir.

2> file:del_dir("/this/dir/will/soon/be/gone").
ok

The function deletes the given directory if it exists, returning ok if successful. An error will be returned if any part of the directory path is not a directory.


Comments about this recipe

Contributors

Based on work by IvanHernandez.

-- BrentAFulgham - 03 Sep 2004

CookbookForm
TopicType: Recipe
ParentTopic: FileRecipes
TopicOrder: 100

 
 
Copyright © 2004 by the contributing authors. All material on the Erlang Cookbook web site is the property of the contributing authors.
This material can be redistributed and/or modified under the terms of the GNU Lesser General Public License (LGPL), version 2.1, as published by the Free Software Foundation.
Ideas, requests, problems regarding Schematics Cookbook? Send feedback.
/ You are Main.guest