Solved

get the path of the file.. Extractfilepath

Posted on 2003-10-25
10
332 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
ID: 9619096
? there is a function named Extractfilepath
? have you to search first
0
 
LVL 2

Assisted Solution

by:ccrdude
ccrdude earned 50 total points
ID: 9619122
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
ID: 9624364
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
ID: 9625848
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Assisted Solution

by:ttd
ttd earned 50 total points
ID: 9640938
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
ID: 9667532
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
ID: 9667552
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
ID: 9667558
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Activex get website that activex running on 3 85
Firemonkey webbrowser scrollbars ? 1 29
CheckListBox usage 3 48
Graphics32 under Delphi 10.1 Berlin 2 34
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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

930 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

11 Experts available now in Live!

Get 1:1 Help Now