如何从E.Url.Tostring()获取文件名 [英] How Do I Get Only The File Name From E.Url.Tostring()

查看:85
本文介绍了如何从E.Url.Tostring()获取文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!

i有更低的代码价格



引用:

Private Sub WebKitBrowser1_Navigating(ByVal sender As System.Object,ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs)处理WebKitBrowser1.Navigating

如果是e.Url.ToString()。EndsWith(。jpg )或e.Url.ToString()。EndsWith(。bmp)或e.Url.ToString()。EndsWith(。gif)或e.Url.ToString()。EndsWith(。png)或e.Url.ToString()。EndsWith(。jpeg)然后

e.Cancel = True

//仅从网址获取图片名称/>
End Sub





我的问题是:我如何只从该网址获取图片名称?



这个:E:\ Pictures \1080p \ Christmas \ image.jpg就是一个例子。

谢谢

解决方案

尝试:

  string  filenameWithExtension = Path.GetFileName( @  E:\Pictures\1080p \ Christmas \ image.jpg); 





  string  filenameWithoutExtension = Path.GetFileNameWithoutExtension( @  E:\ Pictures \\ \\1080p\Christmas\image.jpg); 


Hello !
i have the bellow pice of code

Quote:

Private Sub WebKitBrowser1_Navigating(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs) Handles WebKitBrowser1.Navigating
If e.Url.ToString().EndsWith(".jpg") Or e.Url.ToString().EndsWith(".bmp") Or e.Url.ToString().EndsWith(".gif") Or e.Url.ToString().EndsWith(".png") Or e.Url.ToString().EndsWith(".jpeg") Then
e.Cancel = True
// get the image name only from the url
End Sub



My question is : How do i get only the image name from that url ?

this : E:\Pictures\1080p\Christmas\image.jpg is an example.
Thank you

解决方案

Try:

string filenameWithExtension = Path.GetFileName(@"E:\Pictures\1080p\Christmas\image.jpg");


Or

string filenameWithoutExtension = Path.GetFileNameWithoutExtension(@"E:\Pictures\1080p\Christmas\image.jpg");


这篇关于如何从E.Url.Tostring()获取文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆