亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

獲取Shell使用的文件圖標

獲取Shell使用的文件圖標

FFIVE 2019-11-29 10:29:22
在.Net(C#或VB:無關)中,給定文件路徑字符串,FileInfo結構或FileSystemInfo結構用于實際的現有文件,我如何確定外殼程序(瀏覽器)為此使用的圖標文件?我目前不打算將其用于任何用途,但是當看到這個問題時,我對如何做到這一點感到好奇,并且我認為將其存檔在SO上將很有用。
查看完整描述

3 回答

?
慕妹3146593

TA貢獻1820條經驗 獲得超9個贊

Imports System.Drawing

Module Module1


    Sub Main()    

        Dim filePath As String =  "C:\myfile.exe"  

        Dim TheIcon As Icon = IconFromFilePath(filePath)  


        If TheIcon IsNot Nothing Then    

            ''#Save it to disk, or do whatever you want with it.

            Using stream As New System.IO.FileStream("c:\myfile.ico", IO.FileMode.CreateNew)

                TheIcon.Save(stream)          

            End Using

        End If

    End Sub


    Public Function IconFromFilePath(filePath As String) As Icon

        Dim result As Icon = Nothing

        Try

            result = Icon.ExtractAssociatedIcon(filePath)

        Catch ''# swallow and return nothing. You could supply a default Icon here as well

        End Try

        Return result

    End Function

End Module


查看完整回答
反對 回復 2019-11-29
  • 3 回答
  • 0 關注
  • 695 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號