Solved

get the path of the file.. Extractfilepath

Posted on 2003-10-25
10
328 Views
Last Modified: 2010-04-05
Hi, i was wondering if we can get the full path of the filename?

my questions is how about if the there are 2 to 3 files with thesame filename
but different directories? pls give me a detail explanation.. thanks..
0
Comment
Question by:orafans
10 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 50 total points
Comment Utility
? there is a function named Extractfilepath
? have you to search first
0
 
LVL 2

Assisted Solution

by:ccrdude
ccrdude earned 50 total points
Comment Utility
I guess you are looking for ExpandFilename, which expands a simple filename with the path (if that can be determinded)?
0
 

Assisted Solution

by:huiyue
huiyue earned 50 total points
Comment Utility
Maybe the following function will help you!

Findfirst();Findnext;Findclose;FileSearch();

You can get help's detail from delphi.
Good luck!
HuiYue
0
 

Author Comment

by:orafans
Comment Utility
can you give me an example please cause i have tried using the extractfilepath with a filename that are found in many directories but it returns null of empty.. thanks.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 1

Assisted Solution

by:ttd
ttd earned 50 total points
Comment Utility
Hi,

Assume that you have a file name with full path. The ExtractFilePath will return the path name of that file.

To get a full name of a file, you can:

1. Use ExpandFileName or ExpandUNCFileName if you have a short file name. But remember that these two functions work only for files in current directory (for relative file name).

2. Use Findfirst();Findnext;Findclose;FileSearch(); recursively to build up the full path of the file that they found. When you found a directory and pass it recursively into inner level, you should store that directory and build up the path, so when you got a file name, its path would be already built and you can use it.

Regards,

ttd
0
 
LVL 5

Assisted Solution

by:Hypoviax
Hypoviax earned 50 total points
Comment Utility
extractfilepath is only useful if you have a known variable such as in the case:

FILEPATH:=extractfilepath(application.exename);

In this case extractfile will return where the application is present.

I will get back to on Find first find next example.

Regards,

Hypoviax
0
 
LVL 5

Expert Comment

by:Hypoviax
Comment Utility
This is how you use findfirst and findnext:



var
 FileName: string;
 FindHandle:THandle;
 SearchRec:TWIN32FindData;
begin
 try
  FindHandle := FindFirstFile('C:\*.*', SearchRec);
//where C:\*.* specifys the Directory and the file extension that you want to find.
//It can be the full path too.
  if FindHandle <> INVALID_HANDLE_VALUE then
  repeat
   FileName:=SearchRec.cFileName;
   ListBox1.Items.Add (FileName);
  until FindNextFile(FindHandle,SearchRec)=false;
  finally
   FindClose(FindHandle);
  end;
end;

Regards,

Hypoviax
0
 
LVL 5

Expert Comment

by:Hypoviax
Comment Utility
IF you have no idea whatsoever as to where the file are located you will need to perform recursion using findfirst and findnext. This is very hard and i have no available code to show you. Your best bet is to use findfirst, findnext by specifying the directory and the files.

Hope all this helps,

Hypoviax
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video discusses moving either the default database or any database to a new volume.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now