Andrei20193
Andrei20193

Reputation: 469

How to cut a String in VB.NET?

I have that string ...

C:\Users\ApplicationData\Folder1\Myapp.exe

How could i cut like:

C:\Users\ApplicationData\Folder1

I have tried s.split("\Myapp.exe") , where s is C:\Users\ApplicationData\Folder1\Myapp.exe

Plase help me, thanks.

Upvotes: 0

Views: 340

Answers (2)

Sanfoor
Sanfoor

Reputation: 323

you can use the System.IO.FileInfo class.
It contains a function FullName, which returns the directory full name. check this link

Upvotes: 1

Matías Fidemraizer
Matías Fidemraizer

Reputation: 64923

Use the Path class:

Path.GetDirectoryName("C:\Users\ApplicationData\Folder1\Myapp.exe")

Check it here:

Upvotes: 11

Related Questions