Solved

splitting a filename into its components

Posted on 1999-01-10
2
167 Views
Last Modified: 2010-04-06
Hi experts,

suppose we have a file:

filename:='c:\programs\windows\my file.txt';

how can I split this filename into its components?

drive:='c:';
directory:='\programs\windows\';
name:='my file';
extension:='.txt';


With kind regards

Mathes
0
Comment
Question by:mathes
  • 2
2 Comments
 
LVL 20

Accepted Solution

by:
Madshi earned 10 total points
ID: 1355708
Hi Mathes,

drive:=ExtractFileDrive(filename);
directory:=ExtractFilePath(filename);
Delete(directory,1,length(drive));
name:=ExtractFileName(filename);
extension:=ExtractFileExt(filename);
Delete(name,length(name)+1-length(extension),maxInt);

Regards, Madshi.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1355709
Hmm. Normally it's this way:

drive:='c:\';
directory:='programs\windows\';

If you want to have it the other way round, add this line after the "drive:=..." line:

Delete(drive,length(drive),1);
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
creating manifest for my dll that called from activex 6 91
Convert Jpg /PNG To GIF 5 103
delphi exception 7 58
Delphi inherited method 6 42
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 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