删除文件结尾并仅显示带有图像的文件名 [英] removing the file ending and display just the file name with an image

查看:83
本文介绍了删除文件结尾并仅显示带有图像的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始创建一个应用程序启动器,该应用程序从文件夹中提取应用程序快捷方式,并用图标列出它们,然后单击以打开应用程序.

我遇到的问题是,当我运行它时,在快捷方式末尾出现.lnk,而我想要的只是名称.帮助将非常有用,请不要链接到其他项目以供阅读,我需要代码方面的帮助.

I started creating an application launcher that pulls application shortcuts from a folder and list them with the icon and on click the application opens.

The issue im having is when i run it i get .lnk at the end of the shortcuts and all i want is just the name. Help would be great and please no links to other items to read i need help with the code.

Private Sub Application_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim Dir As New DirectoryInfo("C:\Remote Tools")
FillListView(Dir)

end sub









Private Sub FillListView(ByVal Folder As DirectoryInfo)
        Static ImageList As New ImageList With {.ColorDepth = ColorDepth.Depth32Bit, .ImageSize = New Size(20, 20)}
        Static ImgIndex As Integer = 0

        ListView1.LargeImageList = ImageList
        ListView1.View = View.Tile


        For Each F As FileInfo In Folder.GetFiles("*.lnk")
            ImageList.Images.Add(Drawing.Icon.ExtractAssociatedIcon(F.FullName))
            ListView1.Items.Add(F.Name, ImgIndex).Tag = F
            ImgIndex += 1
        Next


        For Each Dir As DirectoryInfo In Folder.GetDirectories
            FillListView(Dir)
        Next
    End Sub

推荐答案

认真阅读MSDN文档.

Path类中的以下功能以及其他功能会通过文件名操作使您烦恼不已.

Path.GetFileNameWithoutExtension方法 [
Seriously, read MSDN documentation.

The following function and a buch of other in that Path class will hell you a lot with file name manipulation.

Path.GetFileNameWithoutExtension Method [^]

By the way, Google is a good tool to find in seconds the answer to such questions.


这篇关于删除文件结尾并仅显示带有图像的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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