开发者

VB.NET: Remove the .png from name

开发者 https://www.devze.com 2023-02-03 07:47 出处:网络
\"Image.png\" How do I remove the .png part? My program seems to be having tr开发者_StackOverflow社区ouble with it..Does this work?

"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

精彩评论

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