Sign in to follow this  
ajm113

Struggling With Removing a File? (C++)

Recommended Posts

I must be forgetting something, but the remove function with "std" doesn't work for me. I have it working like so:
		char Path[256];
		sprintf(Path, "GameFolders\\%s\\%s\\%s", str.Email, str.GameName, str.fileName);

remove((const char*)Path);


I'm using this function on Windows platform. Do I need a "full length" path to that file for it to delete? I want to recreate a file in it's place, but I have to remove it first before I recreate it. :S Thank you, sorry this question seems to be kinda low level for me, but I guest we all can't know or remember everything.

Share this post


Link to post
Share on other sites
I believe the problem to be that std::remove has nothing to do with files. ;-)

If you're on Windows, use ::DeleteFile(path). If you're using boost, you can use boost::filesystem::remove(). but std::remove is for a completely different purpose.

Share this post


Link to post
Share on other sites
I mean this remove function not the std then. hehe, I tried that as well and it returns false all the time. I'm guesting it's a value issue? Here is Path's
value = "GameFolders\Accounts\myEmail@yahoo.com\SomeGame\myGame.txt".

Share this post


Link to post
Share on other sites
[EDIT]
Oh I didn't close a handle that was created before that. >,< Alright well it works now! Thank you guys!

[Edited by - ajm113 on March 10, 2010 12:13:33 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this