I am selecting a list of files based on a criteria using Dir, and then storing these in an array of strings. I then iterate through the array and process the files.
How can i handle filenames with unicode characters?
I tried to do StrConv
but it didn't help.
vfile = Dir(vCurrDir & vCrit, vbNormal) 'vCrit is something like *test*
Then later I'll try to access the file's properties like this:
vfilename = vCurrDir & "\" & vfile
Set objFSO = CreateObject("Scripting.FileSystemObject")
vDateMod = objFSO.GetFile(vfilename).datelastmodified
at the last line I get an error-message that the File is not found. This only happens for filenames with unicode characters.
There was another post regarding this here: Working with Unicode file names in VBA (using Dir, FileSystemObject, etc.), but it didnt solve the problem with
Dir`.
My Example: VBA (watch) c:\my-test-file.pdf Unicode: c:\my‐test‐file.pdf
(you cannot see the difference here but if you copy the names and paste them into Notepad++ you'll see that the dashes are different characters for the two files, VBA is converting the unicode dash character into a windows locale dash)
Or the example from the linked question: 3_Połish.txt (in Unicode) vs 3_Polish.txt (in VBA)