Solved

get the path of the file.. Extractfilepath

Posted on 2003-10-25
10
343 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses
Course of the Month8 days, 13 hours left to enroll

617 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