DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Any visual basic 6.0 pros out there? I need some help with a formless vb app

  1. #1
    Karl E. Peterson Guest

    Re: Any visual basic 6.0 pros out there? I need some help with a formless vb app

    Hi Dan --

    > I am writing a vb console application, I need to know how to select all of
    > the files in a directory through the commandline.
    > I have my program searching the contents of the c:drive for a given directory,
    > once the directory is found, I need to select all of the files contained
    > in the directory and transfer them to an archive. I have been searching
    > for answers for weeks now!


    What aspect of this are you having problems with? (Did you take a look at the Dir
    function in the Help?)

    Later... Karl
    --
    [Microsoft Basic: 1976-2001, RIP]


  2. #2
    Dan Guest

    Any visual basic 6.0 pros out there? I need some help with a formless vb app


    I am writing a vb console application, I need to know how to select all of
    the files in a directory through the commandline.
    I have my program searching the contents of the c:drive for a given directory,
    once the directory is found, I need to select all of the files contained
    in the directory and transfer them to an archive. I have been searching
    for answers for weeks now!
    I need your help!

    If anyone knows how to do this, It would be greatly appreciated!
    thank you

  3. #3
    Guest

    Re: Any visual basic 6.0 pros out there? I need some help with a formless vb app


    Karl,

    I did look at the DIR function in the help, but I need to transfer the files,
    rather the contents of the files, into a single file for later compression.

    I am having problems figuring out how to select the selected files and move
    them. (like the common dialog would allow, but from the command line)
    does this make sense?

    Dan

    "Karl E. Peterson" <karl@mvps.org> wrote:
    >Hi Dan --
    >
    >> I am writing a vb console application, I need to know how to select all

    of
    >> the files in a directory through the commandline.
    >> I have my program searching the contents of the c:drive for a given directory,
    >> once the directory is found, I need to select all of the files contained
    >> in the directory and transfer them to an archive. I have been searching
    >> for answers for weeks now!

    >
    >What aspect of this are you having problems with? (Did you take a look

    at the Dir
    >function in the Help?)
    >
    >Later... Karl
    >--
    >[Microsoft Basic: 1976-2001, RIP]
    >



  4. #4
    Karl E. Peterson Guest

    Re: Any visual basic 6.0 pros out there? I need some help with a formless vb app

    Hi Dan --

    Okay, well, there's a semantic issue here. "Selection" is something *users* do. <g>
    You're a developer now, so we gotta get you thinking like one. <g>

    The Dir function will help you go through an entire directory, one file at a time.
    You'll want to open your destination file for output (note, lowercase "O" there),
    then one at a time open each source file and write its contents to the destination.
    Not a very common task, so unlikely you'll find any existing code that already does
    just this. I'd have to advise staying away from the File System Objects for this
    task, assuming I understand what you're up to.

    This is really just pretty standard file i/o. My suggestion would be to first write
    a loop that outputs the name of each file. Get that working. Then, take a look at
    i/o examples out there. I posted an example just this morning (to
    vb.getting.started) showing how to read an entire file into a string:

    Dim hFile As Long
    Dim Buffer As String
    hFile = FreeFile
    Open "whatever.htm" For Binary As #hFile
    Buffer = Space$(LOF(hFile))
    Get #hFile, , Buffer
    Close #hFile

    You could then write the contents of Buffer to your destination. (If these files are
    *huge*, as in 10s of MB, your task is going to be more rigorous, requiring multiple
    read/writes for each.) Make sense?

    Later... Karl
    --
    [Microsoft Basic: 1976-2001, RIP]


    <vb.@127.0.0.1> wrote in message news:3d20b869$1@10.1.10.29...
    >
    > Karl,
    >
    > I did look at the DIR function in the help, but I need to transfer the files,
    > rather the contents of the files, into a single file for later compression.
    >
    > I am having problems figuring out how to select the selected files and move
    > them. (like the common dialog would allow, but from the command line)
    > does this make sense?
    >
    > Dan
    >
    > "Karl E. Peterson" <karl@mvps.org> wrote:
    > >Hi Dan --
    > >
    > >> I am writing a vb console application, I need to know how to select all

    > of
    > >> the files in a directory through the commandline.
    > >> I have my program searching the contents of the c:drive for a given directory,
    > >> once the directory is found, I need to select all of the files contained
    > >> in the directory and transfer them to an archive. I have been searching
    > >> for answers for weeks now!

    > >
    > >What aspect of this are you having problems with? (Did you take a look

    > at the Dir
    > >function in the Help?)
    > >
    > >Later... Karl
    > >--
    > >[Microsoft Basic: 1976-2001, RIP]
    > >

    >



  5. #5
    John Guest

    Re: Any visual basic 6.0 pros out there? I need some help with a formless vb app


    Dan,

    The FileSystemObject is what you're looking for. It will appear in IntelliSense
    once you add a reference to the scrrun.dll (Microsoft Scripting Runtime).

    The FileSystemObject contains numerous objects to manipulate files and is
    well worth investigating if you do any kind of file I/O.

    The following sample code will move files from one directory to another.

    Dim fsoLocal As Scripting.FileSystemObject
    Set fsoLocal = New Scripting.FileSystemObject
    fsoLocal.MoveFile "C:\OldPath\*.*", "C:\NewPath"
    Set fsoLocal = Nothing

    The object also contains methods to copy, delete and detect the existence
    of files and folders. Use the MSDN library that comes with VB for additional
    info.

    John

    "Dan" <vb.@127.0.0.1> wrote:
    >
    >I am writing a vb console application, I need to know how to select all

    of
    >the files in a directory through the commandline.
    >I have my program searching the contents of the c:drive for a given directory,
    >once the directory is found, I need to select all of the files contained
    >in the directory and transfer them to an archive. I have been searching
    >for answers for weeks now!
    >I need your help!
    >
    >If anyone knows how to do this, It would be greatly appreciated!
    >thank you



  6. #6
    Dan Guest

    Re: Any visual basic 6.0 pros out there? I need some help with a formless vb app


    Karl,

    That makes sense, I think I've been overthinking it.

    Thanks,
    Dan

    "Karl E. Peterson" <karl@mvps.org> wrote:
    >Hi Dan --
    >
    >Okay, well, there's a semantic issue here. "Selection" is something *users*

    do. <g>
    >You're a developer now, so we gotta get you thinking like one. <g>
    >
    >The Dir function will help you go through an entire directory, one file

    at a time.
    >You'll want to open your destination file for output (note, lowercase "O"

    there),
    >then one at a time open each source file and write its contents to the destination.
    >Not a very common task, so unlikely you'll find any existing code that already

    does
    >just this. I'd have to advise staying away from the File System Objects

    for this
    >task, assuming I understand what you're up to.
    >
    >This is really just pretty standard file i/o. My suggestion would be to

    first write
    >a loop that outputs the name of each file. Get that working. Then, take

    a look at
    >i/o examples out there. I posted an example just this morning (to
    >vb.getting.started) showing how to read an entire file into a string:
    >
    > Dim hFile As Long
    > Dim Buffer As String
    > hFile = FreeFile
    > Open "whatever.htm" For Binary As #hFile
    > Buffer = Space$(LOF(hFile))
    > Get #hFile, , Buffer
    > Close #hFile
    >
    >You could then write the contents of Buffer to your destination. (If these

    files are
    >*huge*, as in 10s of MB, your task is going to be more rigorous, requiring

    multiple
    >read/writes for each.) Make sense?
    >
    >Later... Karl
    >--
    >[Microsoft Basic: 1976-2001, RIP]
    >
    >
    ><vb.@127.0.0.1> wrote in message news:3d20b869$1@10.1.10.29...
    >>
    >> Karl,
    >>
    >> I did look at the DIR function in the help, but I need to transfer the

    files,
    >> rather the contents of the files, into a single file for later compression.
    >>
    >> I am having problems figuring out how to select the selected files and

    move
    >> them. (like the common dialog would allow, but from the command line)
    >> does this make sense?
    >>
    >> Dan
    >>
    >> "Karl E. Peterson" <karl@mvps.org> wrote:
    >> >Hi Dan --
    >> >
    >> >> I am writing a vb console application, I need to know how to select

    all
    >> of
    >> >> the files in a directory through the commandline.
    >> >> I have my program searching the contents of the c:drive for a given

    directory,
    >> >> once the directory is found, I need to select all of the files contained
    >> >> in the directory and transfer them to an archive. I have been searching
    >> >> for answers for weeks now!
    >> >
    >> >What aspect of this are you having problems with? (Did you take a look

    >> at the Dir
    >> >function in the Help?)
    >> >
    >> >Later... Karl
    >> >--
    >> >[Microsoft Basic: 1976-2001, RIP]
    >> >

    >>

    >



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