sunshine737
asked on
filename without extension in VB.NET
Hi
i am having filename as "countrylist____23456.html "
1) i want to extract Only the file Name (NOT Extension)
2)and from the filename for eg.here "countrylist____23456",ext ract last 5 characters,
in this case "23456"
thanks for your reply
regards
i am having filename as "countrylist____23456.html
1) i want to extract Only the file Name (NOT Extension)
2)and from the filename for eg.here "countrylist____23456",ext
in this case "23456"
thanks for your reply
regards
ASKER
oFileInfo.Name prints filename with extension . "countrylist____23456.html "
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
or
Dim oFileInfo As New System.IO.FileInfo("c:\C:\ countrylis t____23456 .html")
Dim g As String = oFileInfo.Name
g = g.Replace(oFileInfo.Extens ion.ToStri ng, "")
g = g.Substring(g.Length - 5)
Dim oFileInfo As New System.IO.FileInfo("c:\C:\
Dim g As String = oFileInfo.Name
g = g.Replace(oFileInfo.Extens
g = g.Substring(g.Length - 5)
hi there... use System.IO.Path
MsgBox(System.IO.Path.GetF ileNameWit houtExtens ion("C:\My Doc01.doc" ))
-Baan
MsgBox(System.IO.Path.GetF
-Baan
guess , you don't like single line code ... :(
dim oFileInfo as New System.IO.FileInfo("countr
debug.WriteLine(oFileInfo.
I'm not sure if the above prints the extension as well.
If it does, you can trim out the extension since the property oFileInfo.Extension gives you the extension string.
hope this helps..
Imran