Results 1 to 6 of 6

Thread: file name

  1. #1

    Thread Starter
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946
    'I want to list the file names but not
    'sure how to call them

    myFolder = "a:\image viewer\images"
    Dim FSO As Object
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set FSO = FSO.GetFolder(myFolder)

    iLen = FSO.Files.Count

    ReDim iArray(iLen)
    For iCount = 1 To iLen

    iArray(iCount) = 'how do I get the file name here

    List1.AddItem iArray(iCount)
    Next
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  2. #2
    Addicted Member
    Join Date
    May 2000
    Posts
    142
    try something like this instead;

    Code:
    Set objFilesys = CreateObject("Scripting.FileSystemObject")
    Set objFolder = objFilesys.GetFolder(strFolderPath)
    Set collFiles = objFolder.Files
    
    For Each objFile in collFiles
    
    '..do whatever you want with the file name
    '..i.e store to an array
    
    Next
    good luck

    /d8/

  3. #3

    Thread Starter
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    ..the best...

    works like a charm...all I wanted to do
    was to uppercase all the filenames in a
    given folder and your way beats the crap
    out of my idea...

    thanks...
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  4. #4
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    Or altreantivley, if you do not want to have to include the scripting runtime libraries with your project.

    Code:
    Dim stFile as String
    
    stFile = Dir$("c:\path\*.*")
    
    Do While stFile <> ""
      List1.Additem stFile
      stFile = Dir
    Loop
    Iain, thats with an i by the way!

  5. #5
    Addicted Member
    Join Date
    May 2000
    Posts
    142
    me = one-upped !!

    Secret to long life:
    Keep breathing as long as possible.

  6. #6

    Thread Starter
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    scripting

    Yup...I use it for two or three other functions in the app so I have to load it...

    will keep the (without fso code)..add it to my database for future reference..

    thanks
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width