开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜