How to derive the path of a filename without the filename

  • Thread starter Thread starter Shadowboxer
  • Start date Start date
S

Shadowboxer

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
 
Hello,

Shadowboxer said:
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'.
 
Shadowboxer said:
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
 
Hello,

Cor said:
When you not want to do some IO just use Split
or Lastindexof

Using 'System.IO.Path.GetDirectoryName' doesn't perform any IO operations.
 
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
 
Hello,

Cor said:
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.
 
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
 
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
 
Back
Top