VB.NET: Remove the .png from name
"Image.png"
How do I remove the .png part? My program seems to be having tr开发者_StackOverflow社区ouble with it..
Does this work?
Dim fileName As String = System.IO.Path.GetFileNameWithoutExtension("Image.png")
If you can know that the name will not have another dot(.) in it, this should work.
Dim filename As String = "image.png"
filename = filename.split(".")(0)
If on the otherhand, the filename is from some user input, this will not work. For example, there could be file names like
sunset.greek.png
In which case my code would return only the sunset
.
精彩评论