Struggling With Removing a File? (C++)

Started by
5 comments, last by ajm113 14 years, 1 month ago
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.
Check out my open source code projects/libraries! My Homepage You may learn something.
Advertisement
What's the error?
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.
Quote:Original post by cache_hit
I believe the problem to be that std::remove has nothing to do with files. ;-)


That's what I also thought at first, but...
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".
Check out my open source code projects/libraries! My Homepage You may learn something.
Quote:Original post by ajm113
it returns false


Precisely, it returns an integer. So it returns 0. That means success.
[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]
Check out my open source code projects/libraries! My Homepage You may learn something.

This topic is closed to new replies.

Advertisement