473,387 Members | 2,436 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,387 software developers and data experts.

How to derive the path of a filename without the filename

Hi there!

I seem to have stumbled on to something that I just cant remember how to
do, I could do it in vb6.

I need to get this result

C:\x\y\z\

from the string:
C:\x\y\z\abc.123
any ideas?

THANKS! -S
Nov 20 '05 #1
15 14803
Hello,

"Shadowboxer" <sh*********@mac.com> schrieb:
I need to get this result

C:\x\y\z\

from the string:
C:\x\y\z\abc.123


Have a look at 'System.IO.Path.GetDirectoryName'.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #2
> I need to get this result

C:\x\y\z\

from the string:
C:\x\y\z\abc.123
any ideas?

System.IO.Path.GetDirectoryName()

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 20 '05 #3
"Shadowboxer" <sh*********@mac.com> schrieb
I seem to have stumbled on to something that I just cant remember
how to
do, I could do it in vb6.

I need to get this result

C:\x\y\z\

from the string:
C:\x\y\z\abc.123

System.IO.Path.GetDirectoryName
--
Armin

Nov 20 '05 #4
cool! thanks
"Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> wrote in message
news:ut**************@TK2MSFTNGP12.phx.gbl...
Hello,

"Shadowboxer" <sh*********@mac.com> schrieb:
I need to get this result

C:\x\y\z\

from the string:
C:\x\y\z\abc.123


Have a look at 'System.IO.Path.GetDirectoryName'.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet

Nov 20 '05 #5
Cor
Hi Shadowboxer,
When you not want to do some IO just use Split or Lastindexof
Cor
Nov 20 '05 #6
Hello,

"Cor" <no*@non.com> schrieb:
When you not want to do some IO just use Split
or Lastindexof


Using 'System.IO.Path.GetDirectoryName' doesn't perform any IO operations.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #7
Cor
Ok Ok , mistinking of me, but only for you and not for the OP

When you do not want to use import system.io

I was just telling the alternative.

Cor
Nov 20 '05 #8
Hello,

"Cor" <no*@non.com> schrieb:
Ok Ok , mistinking of me, but only for you and not for
the OP

When you do not want to use import system.io

I was just telling the alternative.


No problem. I think it's good that you tell the people about alternative
methods, so they get familiar with the string functions.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #9
When you do not want to use import system.io


Why would you not want to do that?

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 20 '05 #10
Cor
Hi Mattias
To write one line less

No let me bring it more in a more sensible level.

This was the question
I need to get this result
C:\x\y\z\
from the string:
C:\x\y\z\abc.123


That you can do that with System.IO.Path.GetDirectoryName is very clever,
but helps the OP only one time. My idea was that giving him the direction to
the string members or the Visual.Basic functions would help him maybe more
in future when he has to do a string conversion.

But why should I write that, this newsgroup get compliment because the
discussions between the regulars are almost always on a nice level and this
has in my opinion not the value to make a discussion about it. Therefore OT.

Clear?

Cor

Nov 20 '05 #11
Cor
Hi Mattias
To write one line less

No let me bring it more in a more sensible level.

This was the question
I need to get this result
C:\x\y\z\
from the string:
C:\x\y\z\abc.123


That you can do that with System.IO.Path.GetDirectoryName is very clever,
but helps the OP only one time. My idea was that giving him the direction to
the string members or the Visual.Basic functions would help him maybe more
in future when he has to do a string conversion.

But why should I write that, this newsgroup get compliment because the
discussions between the regulars are almost always on a nice level and this
has in my opinion not the value to make a discussion about it. Therefore OT.

Clear?

Cor

Nov 20 '05 #12
Hello,

"Cor" <no*@non.com> schrieb:
Therefore OT.


EOT

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #13
Hello,

"Cor" <no*@non.com> schrieb:
Therefore OT.


EOT

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #14
Can u make do with App.Path ? Or if u want to do it programmatically,
use the Mid function retrieve chars till the '.' and then go back the
filename number of chars till '/' and u got it. But I suggest u do it
the first way.

with regards,
J.V.Ravichandran
- http://www.geocities.com/
jvravichandran
- http://www.411asp.net/func/search?
qry=Ravichandran+J.V.&cob=aspnetpro
- http://www.southasianoutlook.com
- http://www.MSDNAA.Net
- http://www.csharphelp.com
- http://www.poetry.com/Publications/
display.asp?ID=P3966388&BN=999&PN=2
- Or, just search on "J.V.Ravichandran"
at http://www.Google.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #15
Can u make do with App.Path ? Or if u want to do it programmatically,
use the Mid function retrieve chars till the '.' and then go back the
filename number of chars till '/' and u got it. But I suggest u do it
the first way.

with regards,
J.V.Ravichandran
- http://www.geocities.com/
jvravichandran
- http://www.411asp.net/func/search?
qry=Ravichandran+J.V.&cob=aspnetpro
- http://www.southasianoutlook.com
- http://www.MSDNAA.Net
- http://www.csharphelp.com
- http://www.poetry.com/Publications/
display.asp?ID=P3966388&BN=999&PN=2
- Or, just search on "J.V.Ravichandran"
at http://www.Google.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #16

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

Similar topics

6
by: Joe | last post by:
If I have a search submit button, when I click submit button, it will submit the form to search.asp for form processing. This will be the URL: http://www.mycompany.com/search.asp?q=programming ...
4
by: Diarmaid | last post by:
Hi! I've built a dynamic navigation system which compares the filename in the document URL with the filename in the navigation link in order to determine which link to highlight as "active". ...
1
by: Andres Romero | last post by:
Using the FielDialog class and it's FileName propertie I can know the Path and file name selected by the user, but now I need to know only the file name without the full path (eg....
6
by: Peter Proost | last post by:
Hi group, I've got a program that creates a bat and a sql file and then executes the bat file the bat file is called temp.bat and looks like this: osql -U"user" -P"password"...
2
by: mark | last post by:
When I use a OpenFileDialog to open a file I get a filename: OpenFileDialog1.FileName It is a complete filespec including directories and drive. Can a name only string be obtained withour...
6
by: Mohammad Omer | last post by:
Hi, I tried to validate file path without calling file creating functions. Is it possible? How? Regards, -aims
8
by: sheriff | last post by:
Hi friends, I am opening and reading a file and writing it in a new file. int main() { ifstream inputFile("C:\\TEMP\\test.txt"); ofstream outputFile; ...
3
by: Andy | last post by:
Hi I have a filedialog that returns the entire path and the filename of a given file. How can I remove the filepath from the filename property and only have the basic filename. Say I have a...
1
by: newton2000 | last post by:
How can I use the preprocessor functions to get the __FILE__ macro only with the filename (without the path). The reason is that the objects are different when complied on different machines...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.