Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

get the path of the file.. Extractfilepath

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

Assisted Solution

by:ccrdude
ccrdude earned 200 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 200 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 200 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 200 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
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 course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

719 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