Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Api or delphi function to have the previous directory

Posted on 1999-01-18
3
Medium Priority
?
160 Views
Last Modified: 2010-04-04
Hi,
I want to know if a function or api exist to retreive the previous directory with a string like: 'c:\yes\itsok\'?
Thanks
0
Comment
Question by:mabell
3 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 1362412
What do you mean with the previous directory?

Perhaps you mean "ExtractFilePath"? Or "GetCurrentDir"?

Regards, Madshi.
0
 

Author Comment

by:mabell
ID: 1362413
I mean a function or api similar to extractfilepath but instead of cuting the file name
it cut the second directory. Exemple:  You call this   TheFunctionName('c:\temp1\temp2\')
and obtain this 'c:\temp1\' .
Thanks.
0
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 200 total points
ID: 1362414
This will do it...

function TheFunctionName(Path : string) : String;

begin
  if Path[length(path)] = '\' then
    Path := copy(path, 1, length(path) - 1);

  result := ExtractFilePath(Path);
end;

Cheers,

Raymond.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question