I have this code:
Function cpyBIN(cpFilename As String)
Dim litefile() As Byte
Dim FN As Integer
Dim xlof As Long
FN = 1
Open cpFilename For Binary As FN
xlof = LOF(FN)
ReDim litefile(xlof)
Get FN, , litefile
Open cpFilename & "Backup" For
Binary As #2
Put #2, , litefile
Close #2
Close FN
End Function
and I use it in a Form like this :
Private Sub cmdBackup_Click()
Dim strComputer, objWMIService, colFiles, objfile
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery("Select * from CIM_Datafile where Drive='D:' and path='\\contoh\\'")
For Each objfile In colFiles
cpyBIN (objfile.Name)
Next
End Sub
in the contoh folder there are 2 sample files:
- namafile.exe
- namafile♣♣♠.exe
when I run the code there is an error message like in the picture:
the error is in the line as shown in the picture:
how to make it supports unicode filename? or is there any replacement for this function??