Solved

get the path of the file.. Extractfilepath

Posted on 2003-10-25
10
336 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

823 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