Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is a directory unique?

Status
Not open for further replies.

Robertus

Programmer
Feb 16, 2001
81
RO
How could I find if a directory name is unique?
 
What do you need this for?
If you need it for the creation of a directory you can call CreateDirectory API.If the directory exists, I think GetLastError will return ERROR_ALREADY_EXISTS.

Hope this helps, s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
I need to write a file on a disc and I don't want the name of the file to be the same with the name of an existing directory. So if the directory exists your method will help, but if the directory doesn't exist, a new directory will be created, wich I DON'T WANT !!! (ce mail ai?)
 
The you can use the GetFileAttributes API. If the function fails because the specified file or directory does not exists, will return 0xffffffff.(burtani@operamail.com, tu?)

Hope this helps, s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
you could try chdir as well... if that returns false then the directory does not exist

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top