Solved

Api or delphi function to have the previous directory

Posted on 1999-01-18
3
150 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 50 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

832 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