-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFile.vb
More file actions
41 lines (34 loc) · 1.36 KB
/
Copy pathFile.vb
File metadata and controls
41 lines (34 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Imports System.IO
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Convert
Public Class File
Public Shared Function GetFileExtension(ByVal FileName As String) As String
If InStrRev(FileName, ".") > -1 Then
Return Right(FileName, Len(FileName) - InStrRev(FileName, ".") + 1)
End If
Return ""
End Function
Public Shared Function GetFileIcon(AppDirectoryPath As String, FileName As String) As Icon
Dim FL As New FileInfo(AppDirectoryPath & "\" & FileName)
Dim Img As Icon = Nothing
Try
If Not FL.Exists Then FL.Create().Close()
Img = Icon.ExtractAssociatedIcon(AppDirectoryPath & "\" & FileName)
'Dim Img As Image = Image.FromHbitmap(Ico.ToBitmap.GetHbitmap)
FL.Delete()
Catch ex As Exception
End Try
Return Img
End Function
Public Shared Function GetFileIcon2(ByVal FileName As String) As String
Dim File As New MemoryStream()
Icon.ExtractAssociatedIcon(FileName).ToBitmap.Save(File, ImageFormat.Png)
File.Seek(0, SeekOrigin.Begin)
Return ToBase64String(File.GetBuffer)
End Function
Public Shared Function GetFileIcon3(ByVal IconText As String) As Image
Dim File As New MemoryStream(FromBase64String(IconText))
Return New Bitmap(File)
End Function
End Class