473,398 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

ExtractFilePath() ?

Hi!

I have a path to a file: "C:\dir\file.txt"

How to get directory path? ("C:\dir\")

In Delphi there was a function ExtractFilePath(path). I searched in MSDN and
have not found. Somebody knows?
Nov 17 '05 #1
2 11674
Excuse, I have guessed independently :)

string path = Path.GetDirectoryName(FilePath);
I have a path to a file: "C:\dir\file.txt"

How to get directory path? ("C:\dir\")

In Delphi there was a function ExtractFilePath(path). I searched in MSDN and have not found. Somebody knows?

Nov 17 '05 #2
On Sat, 25 Jun 2005 02:15:38 +0400, "Kostya Ergin"
<ko****@erginsoft.com> wrote:


In Delphi there was a function ExtractFilePath(path). I searched in MSDN and
have not found. Somebody knows?


It seems that I as a Delphi programmer am not the only one struggling
with these kind of questions. I would love to read the book "C# for
Delphi developers", wouldn't you?
GetDirectoryName Returns the directory information for the specified
path string.

string fileName = @"C:\mydir\myfile.ext";
string path = @"C:\mydir\";
string rootPath = @"C:\";
string directoryName;

directoryName = Path.GetDirectoryName(fileName);
Console.WriteLine("GetDirectoryName('{0}') returns '{1}'",
fileName, directoryName);

directoryName = Path.GetDirectoryName(path);
Console.WriteLine("GetDirectoryName('{0}') returns '{1}'",
path, directoryName);

directoryName = Path.GetDirectoryName(rootPath);
Console.WriteLine("GetDirectoryName('{0}') returns '{1}'",
rootPath, directoryName);

Cheers,

chris
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: jenny | last post by:
Hi, I am trying to find a VB way that would create a folder on all existing drives - the folder name would be the same on each drive. ie c:\backup, d:\backup, etc. But the folders would only be...
7
by: Matthew Hanna | last post by:
Is there any code out there to replace the Open File dialog in the common controls? Or, I would like to just make sure that the Explorer item in the context menu doesn't appear when the user right...
1
by: Bo Wisén | last post by:
If I want to decide if a file exists I can use 'if dir("c:\test1\test2\testfile.txt")="testfile.txt"'. But now I want my application to decide if a directory exists and, if not, create it. Maybe...
3
by: zero | last post by:
First a short discription of my program. I have a bot that connects to an internet chess server. Whenever the bot logs on, it loads certain information from file, and puts it in STL containers...
6
by: Verne | last post by:
I was just wondering if anyone else is using this program in the Enterprise edition as I'm a little disgusted with the Tutorial on the Editor. Worked fine withe the exception that one line of code...
9
by: Sonnich | last post by:
Hi! I want to have a number of strings in another file, which I can include everywhere... but I cannot make them reachable from the top file. I have looked at var and global to to this but...
2
by: Diego Armando Maradona | last post by:
Hi, I am using toshiba tec sx8 thermal printer for printing our labels, in My old Delphi application I was using such code; ShellExecute(0,'open',Data.cmdbuffer, PChar('/c copy...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.