String manipulation

anin

Member
Joined
Feb 21, 2005
Messages
10
Programming Experience
1-3
[Resolved] String manipulation

Cud someone please tell me how to truncate the String "TESTFILE.XML" to "TESTFILE"

I want to remove the .xml from the string.

thanks,
 
Last edited:

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
levyuk said:
Dim s AsString = "TESTFILE.XML"
MessageBox.Show(s.Remove(8, 4))

that works, but also limits to the length of the name.ext

String.replace(".xml","") allows for a variable lenth name.ext
 

Paszt

Staff member
Joined
Jun 3, 2004
Messages
1,500
Location
Raleigh, NC - USA
Programming Experience
Beginner
The code given above is perfectly viable.
Another alternative (always good to have alternatives) is:
VB.NET:
Dim strFileName As String = _
          System.IO.Path.GetFileNameWithoutExtension("TESTFILE.XML")
 
Top Bottom