473,506 Members | 13,088 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is there a Windows or C++ library function to break down a Filepath?


My application receives a filepath as an argument. Obviously, it can
come in several formats, such as:

filename.ext

..\filename.ext

...\..\filename.ext

this\is_a\relative\path\finally.ext

C:\fully\qualified\path\filename.ext

....and so on.

In Unix there is a function which will do the right thing in every
case, splitting the path into a base and a filename.

Is there such thing, something equivalent in Windows programming?

TIA,

-Ramon

Oct 22 '07 #1
3 1641
On Oct 22, 1:38 am, "Alf P. Steinbach" <al...@start.nowrote:
* Ramon F Herrera:
My application receives a filepath as an argument. Obviously, it can
come in several formats, such as:
filename.ext
.\filename.ext
..\..\filename.ext
this\is_a\relative\path\finally.ext
C:\fully\qualified\path\filename.ext
...and so on.
In Unix there is a function which will do the right thing in every
case, splitting the path into a base and a filename.
Is there such thing, something equivalent in Windows programming?

Windows programming is off-topic in clc++.
Check out the Boost library's general file handling.

Ooops, I went trigger happy, shot from the hip and didn't even realize
you actually gave some useful info, Alf.

Thanks!

For the record: I am not too fond of the Windows crowd, their ways and
means, and have tried my best to stay on the side of standards,
interoperability (i.e., non-Microsoft), IETF, OSS, etc.

-Ramon
Oct 22 '07 #2
On Oct 22, 8:32 am, Ramon F Herrera <ra...@conexus.netwrote:
My application receives a filepath as an argument. Obviously, it can
come in several formats, such as:

filename.ext

.\filename.ext

..\..\filename.ext

this\is_a\relative\path\finally.ext

C:\fully\qualified\path\filename.ext

...and so on.

In Unix there is a function which will do the right thing in every
case, splitting the path into a base and a filename.

Is there such thing, something equivalent in Windows programming?

TIA,

-Ramon

Look to the Shell Path functions in MSDN.
One of them is PathFindFileName which takes a path and returns the
filename
Oct 23 '07 #3
On 22 Oct, 08:32, Ramon F Herrera <ra...@conexus.netwrote:
My application receives a filepath as an argument. Obviously, it can
come in several formats
Why don't you use boost::filesystem library? It's cross-platform.
Best
John

--
http://John.Torjo.com -- C++ expert
.... call me only if you want things done right
Oct 23 '07 #4

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

Similar topics

0
2718
by: Moluske | last post by:
The web site was on another server i switch to a new one but this server hav now PHP Safe Mode to ON so i get error when creating thumbnail. I cant put PHP Safe mode to OFF. is ther any thing i...
2
15206
by: Ken Lindner | last post by:
I have a need to become familiar with SQL Server 2000 for work. Needless to say I am new to SQL Server any version, but not IT in general. My employer has provided me with the SQL Server 2000...
2
6385
by: Carlos G Benevides | last post by:
I have a ASP.Net web application that has two assemblies that run under com+. Under Windows 2000 the two assemblies are added to com+ automatically when instantiated from the web site. For this...
12
3729
by: Jarod_24 | last post by:
I got a project called "Forms" that hold some forms and stuff in my solution. A argument at startup defines wether to use a From or Console. My plan was to create a myConsole class that would...
3
4673
by: dibblm | last post by:
Below is current code used. I can only list one directory then move to next. I want to search one more directory further and can't seem to find how to get one deeper. What I want to accomplish is...
10
10016
by: morangolds | last post by:
Hi, I've been having a problem with C++ Windows Forms apps not "ending" when you close the form window. I've searched about this problem all over the place and most searches have lead me to...
2
5669
by: Serman D. | last post by:
Hi all, I'm trying to complete the samples from the excellent 2003 developerWorks article "Bringing the Power of Regular Expression Matching to SQL" by Knut Stolze: http://tinyurl.com/3bhrnn...
2
4169
by: =?Utf-8?B?SnJ4dHVzZXIx?= | last post by:
I just started using Windows Live OneCare, I had been using Norton, but was unable to fix the problems I was having. I have yet been unsuccessful with OneCare as well. I keep getting the same...
1
2840
by: =?Utf-8?B?V29vZGdub21l?= | last post by:
Hi, I have use the following code to transmit a file back to the browser that worked fine on a HTC_TTyN device running windows mobile 5.0. The code executes in the onclick event of a mobilelist...
0
7105
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
7371
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...
1
7023
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7479
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
5617
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
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1534
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.