Index Of Parent Directory Windows Iso

Index Of Parent Directory Windows Iso Rating: 4,0/5 1870 reviews

Download toro y moi anything in return zip file free. Men & Mice. www.menandmice.com www.menandmice.com.

Index Of Parent Directory Windows Iso
Active8 years, 5 months ago

I am trying to get the parent directory of the current folder in which i have the program. I need to include in the C program I have. I tried doing it through string methods and solve it, but I feel there can be a better and simpler way. Eg: If his path is “C:ApplicationConfig”, then I want to get - “C:Application” the just parent path.
Can some one please help me with this?

Thanks,Priyanka

Paul R
180k25 gold badges314 silver badges472 bronze badges
PriyankaPriyanka

4 Answers

To in-place truncate a string at its last backslash:

RichieHindleRichieHindle

Index Of Parent Directory Windows Iso

208k40 gold badges311 silver badges373 bronze badges

Sometimes just adding . will suffice if you are not afraid by MAX_PATH.

BenoitBenoit
61.5k17 gold badges173 silver badges214 bronze badges

It's difficult to answer your question since you haven't really specified what you want to -do- with the path once you have it. If you want to change to the new directory, that's easy, you just use whatever function you'd normally use to change directory but pass it '.' instead of a full path - that's because on all sane filesystems, '.' is a 'magic' directory which exists inside all other directories and refers to the parent thereof.

If you want to perform some string function on the new directory before jumping to it, your problem instantly becomes a lot more difficult to solve. The way I'd go about doing it mirrors RichieHindle's solution - strip the current directory away from the full path then you're left with the parent directory's path with which you can muck about to your heart's content.

Chris BrowneChris Browne
1,1601 gold badge10 silver badges26 bronze badges

Index Of Parent Directory Windows 7 Ultimate Iso

In Windows OS, the API function you need is called GetCurrentDirectory().

LundinLundin
118k17 gold badges170 silver badges281 bronze badges
DirectoryIndex

Not the answer you're looking for? Browse other questions tagged cwindowsdos or ask your own question.

Posted :