Jump to content

Delete a file?


tomfmason

Recommended Posts

I wrote a function that will create a directory and add a file to it. Now I am wondering how I can delete a directory and/or a file.

I don't want anyone to write the function for me but rather point me in the right direction i.e.. a link to a relivant section in the manual or an example.

Any suggestions would be great.

Thanks,
Tom
Link to comment
Share on other sites

I tried using
[code=php:0]
chdir ($file_system_path);
exec ("del *.* /s /q");[/code]

And it delted everything in the current directory that I had the file that was running the code. It is a damn good thing that I used a test directory in local host..lol

This is dangerous if you do not know what you are doing.

Thanks,
Tom
Link to comment
Share on other sites

[quote author=tomfmason link=topic=103258.msg411085#msg411085 date=1154944568]
I tried using
[code=php:0]
chdir ($file_system_path);
exec ("del *.* /s /q");[/code]

And it delted everything in the current directory that I had the file that was running the code. It is a damn good thing that I used a test directory in local host..lol

This is dangerous if you do not know what you are doing.

Thanks,
Tom
[/quote]
Indeed. '*.*' will delete all files with an extension as the * character is used as a wildcard, /s flags all sub-directories for deletion, and /q runs in quiet mode - just deleting without prompting.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.