Extracting drive, path filebasename or extension from complete filename?

T

Thomas Lebrecht

Assume I have a full filename like

myfile="D:\aaa\bbb\ccc\ddd.txt"

How can I extract the individual parts (drive, path, filenbase and extension) from it?

How do I get the path and filenam of the current vbs script from inside this script?

Thomas
 
A

Armin Zingler

Thomas Lebrecht said:
Assume I have a full filename like

myfile="D:\aaa\bbb\ccc\ddd.txt"

How can I extract the individual parts (drive, path, filenbase and
extension) from it?

How do I get the path and filenam of the current vbs script from inside
this script?

See

System.IO.Path.Get*

methods.

If you like a different answer, don't post to the VB.Net group
(m.p.dotnet.languages.vb)


Armin
 
O

Onur Güzel

Assume I have a full filename like

myfile="D:\aaa\bbb\ccc\ddd.txt"

How can I extract the individual parts (drive, path, filenbase and extension) from it?

How do I get the path and filenam of the current vbs script from inside this script?

Thomas

In VB.NET (because it seems posted to vb.net group):

Dim path As String = "D:\aaa\bbb\ccc\ddd.txt"

' To get Drive letter
System.IO.Path.GetPathRoot(path)

' To get whole path
System.IO.Path.GetFullPath(path)

' To get extension
System.IO.Path.GetExtension(path)

'...more on System.IO.Path as previously said.

HTH,

Onur Güzel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top