Jump to content
  • Advertisement
Sign in to follow this  
ajm113

Struggling With Removing a File? (C++)

This topic is 3054 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
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...

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!