dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: VB6 How to retrieve all file name from a Folder

  1. #1
    Join Date
    Jan 2005
    Location
    New Zealand
    Posts
    319

    VB6 How to retrieve all file name from a Folder

    Hi Good Friends,
    I need your help. Please help me.

    My company Business Analyst asked me to develop a application to retrieve all the SALESDEPT files names and not the Contents from this folder F:\SalesDept\ and write it to a TEXTFILE and after that save it into this folder F:\ViewFileName

    I have not done it before and doesn't know how to do it. I need your help to share with me sample coding so that I can learned from it.

    Thank you for helping me.
    Last edited by Lennie; 09-27-2010 at 06:35 PM.
    Cheers,
    Lennie

  2. #2
    Join Date
    May 2010
    Posts
    12
    Hi

    Do you have to use VB/VBA, a batch file or simple command issued from the command prompt might do the job. The batch file can be associated with a windows shortcut.

    Batch file lines as follows:-

    @echo off
    cls

    F:

    cd\salesdept

    dir /a:-d /b /o:n > yourfile.txt

    exit

    This batch file will send a directory of the files in the current directory "SalesDept" to a text file of your choice. You can create a batch file in notepad type in the above lines and save it with the file extension .Bat "Your_filename.bat". Run from the command line or associate with a windows shortcut. Type & enter "dir /?" to view all the options & switches associated with Dir. Hope this make sense and is of some use.

    Kev
    Last edited by saltkev; 09-27-2010 at 06:04 AM. Reason: Update

  3. #3
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    Look at the MSDN documentation of the Dir function

    A simple example:

    dim s as string
    s = Dir("F:\SalesDept\*")
    while len(s) > 0
    '' save s into a file
    s = Dir '' get next file
    Wend
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  4. #4
    Join Date
    Jan 2005
    Location
    New Zealand
    Posts
    319
    Quote Originally Posted by mstraf View Post
    Look at the MSDN documentation of the Dir function

    A simple example:

    dim s as string
    s = Dir("F:\SalesDept\*")
    while len(s) > 0
    '' save s into a file
    s = Dir '' get next file
    Wend
    ------------------------------------------------------
    Hi mstraf
    Thank you for trying to help me. Appreciate that very much.
    Regrading your suggestion looking at MSDN what is the URL Address ?

    Regarding the sample coding, The Business Analyst reguest is to retrieve only the File Name and not the content of the file.
    Last edited by Lennie; 09-27-2010 at 06:36 PM.
    Cheers,
    Lennie

  5. #5
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    Quote Originally Posted by Lennie View Post
    Regrading your suggestion looking at MSDN what is the URL Address ?
    You should have MSDN installed in your computer, type DIR in the IDE, click on it and press F1 for help
    Otherwise, you can find the documentation online:

    http://msdn.microsoft.com/en-us/libr...(v=VS.60).aspx

    As you can see, Dir returns the name of the file, not the content...
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

Similar Threads

  1. Replies: 1
    Last Post: 09-24-2007, 04:02 PM
  2. Problem compiling a C++ file in Linux
    By kepler in forum C++
    Replies: 3
    Last Post: 08-26-2007, 12:11 AM
  3. Replies: 2
    Last Post: 07-17-2007, 09:42 PM
  4. open xml file in a different folder
    By blckspder in forum AJAX
    Replies: 0
    Last Post: 03-12-2007, 08:24 PM
  5. How long before the next version??
    By _CAG in forum .NET
    Replies: 146
    Last Post: 08-12-2002, 10:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center