Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

snowball123

Absolute File Path

This topic is 6022 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

Hi, I wondering if there is a function or something to find a file''s absolute path (ex. C:\windows\desktop\myfile.txt ). I''m basically loading a file like this file = fopen ("myfile.txt", "rb"); Is there a way to find the absolute Path from this? Thanks

Share this post


Link to post
Share on other sites
Advertisement
Thanks for the Reply

That works but I was hoping it would validate that the file was there (real file) but I guess that just extra work I have to do.


Here is the C Library version

_fullpath (cFullPath, cFile, 256)


Again Thanks

Share this post


Link to post
Share on other sites
Test the access function:

if ((_access(szFile, 0)) == 0)
{
// The file does exist.
if ((_access(szFile, 4)) == 0)
{
// We have read permission to the file.
}
}
else
{
// The file does not exist.
}


// Dalle

Share this post


Link to post
Share on other sites
To find out if the file exists you can just try to open it, or use GetFileAttributes or something similar.

By the way, there''s really not much point using functions like _fullpath, because it''s not any more portable than GetFullPathName(), which supports unicode better anyway (otherwise you''d have to use _wfullpath or _tfullpath for unicode support...)


codeka.com - Just click it.

Share this post


Link to post
Share on other sites

  • 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!