Foreign Characters in Filename - How to manage

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jrams
    New Member
    • Jun 2007
    • 5

    Foreign Characters in Filename - How to manage

    How to work around / with file names that contain non-Ascii characters, for example "Hush Gounod (Bachú Ave Maria).mp3"

    Iterating through
    Code:
     vStr = Dir("*.*")
    returns files as above. Atempting
    Code:
     Ln = filelen(vstr)
    produces a "File not found" Error 53

    FileSystemObjec t is also unable to "see" this file.

    Are there any workarounds to access such named file?
  • vijay6
    New Member
    • Mar 2010
    • 158

    #2
    Hey Jrams, you can use like this,


    Code:
    Dim list As String() = System.IO.Directory.GetFiles("C:\Users\Public\Music\", "*.mp3") // To get all mp3 format file names including files with Non-ASCII characters
    
    For Each item As var In list
    	MessageBox.Show(item + " " + item.Length) // Display all file names with length.
    Next

    Comment

    • Jrams
      New Member
      • Jun 2007
      • 5

      #3
      vijay6, thanks for your response... but it makes me realize that I somehow got my query posted t the wrong forum. I need a solution in VB6 / VBA. Sorry to not be able to use your prompt help.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        I will move your thread for you but I need to know if it's VB6 or VBA.

        Comment

        • Jrams
          New Member
          • Jun 2007
          • 5

          #5
          Thanks, Rabbit... either will work, perhaps VB6 will have broader application?

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            Well... You'd get a more accurate response if you told me which language you're developing in.

            Comment

            • Jrams
              New Member
              • Jun 2007
              • 5

              #7
              OK... the initial application will be for/in VBA.

              Comment

              • Jrams
                New Member
                • Jun 2007
                • 5

                #8
                One workaround, but not a full solution, I have found:
                var = dir() produces an ASCII result &, hence, the subsequent error

                But originally acquiring the filename via FileSystemObjec t produces an ANSI result:
                Code:
                    Set fso = CreateObject("Scripting.FileSystemObject")
                    Set ff = fso.GetFolder(FolderName)
                    Set f = ff.Files
                    For Each var in f
                Hard to believe that a dir() iteration of say, Spanish filenames, produces an otherwise unusable pointer?

                Comment

                Working...