如何使用vb.net中的路径将文件名存储在标签中 [英] how to store the filename in label using path in vb.net

查看:99
本文介绍了如何使用vb.net中的路径将文件名存储在标签中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从c文件夹中检索草稿文件夹文件名。



在c文件夹文件中如下

C:\Drafts \ AFF.htm。



用于在vb.net中检索文件名代码如下



Dim strpath As String =C:\Drafts\

Foldername = Directory.GetFiles(strpath,*,SearchOption.TopDirectoryOnly)



当我在foldername路径中运行和调试如下



C:\Drafts\AFF.htm。



i在该标签中有一个标签我想存储AFF名称。

在第二次反斜杠AFF之后。

i想在第二次斜线后检索AFF AFF就在那里。



C:\Drafts\AFF.htm

从上面的路径看如何在Back Slash之后获得AFF名称。





我怎样才能在vb.net中编写代码。



问候,

Narasiman P.

解决方案

使用Path类: MSDN [ ^ ]

GetFileName方法只给你一个AFF.htm

GetFileNameWithoutExtension方法只给你一个AFF


I am retrieving the drafts folder file name from c folder.

In c folder file as follows
C:\Drafts\AFF.htm.

for retrieving the filename code as follows in vb.net

Dim strpath As String = "C:\Drafts\"
Foldername = Directory.GetFiles(strpath, "*", SearchOption.TopDirectoryOnly)

When i run and debug in foldername path as follows

C:\Drafts\AFF.htm.

i have one label in that label i want to store the AFF name.
after 2nd backslash AFF is there.
i want to retrieve AFF after 2nd slash AFF is there.

C:\Drafts\AFF.htm
From the above path how to get AFF name after Back Slash.


for that how can i write the code in vb.net.

Regards,
Narasiman P.

解决方案

Use the Path class: MSDN[^]
The GetFileName method will give you just AFF.htm
The GetFileNameWithoutExtension method will give you just the AFF


这篇关于如何使用vb.net中的路径将文件名存储在标签中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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