Getting actual file name (with proper casing) on Windows

前端 未结 7 1002
暗喜
暗喜 2020-12-05 19:29

Windows file system is case insensitive. How, given a file/folder name (e.g. \"somefile\"), I get the actual name of that file/folder (e.g. it should return \"SomeF

7条回答
  •  天命终不由人
    2020-12-05 19:48

    Okay, this is VBScript, but even so I'd suggest using the Scripting.FileSystemObject object

    Dim fso
    Set fso = CreateObject("Scripting.FileSystemObject")
    Dim f
    Set f = fso.GetFile("C:\testfile.dat") 'actually named "testFILE.dAt"
    wscript.echo f.Name
    

    The response I get is from this snippet is

    testFILE.dAt
    

    Hope that at least points you in the right direction.

提交回复
热议问题