By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,699 Members | 1,218 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,699 IT Pros & Developers. It's quick & easy.

How to derive the path of a filename without the filename

P: n/a
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
Share this Question
Share on Google+
15 Replies


P: n/a
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

P: n/a
> 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

P: n/a
"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

P: n/a
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

P: n/a
Cor
Hi Shadowboxer,
When you not want to do some IO just use Split or Lastindexof
Cor
Nov 20 '05 #6

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.