Results 1 to 10 of 10

Thread: Searching Hard Drive for Certain Files then Writing to Server

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2002
    Posts
    55

    Searching Hard Drive for Certain Files then Writing to Server

    I have a couple of questions that maybe you guys can help me out with. I am trying to create an app that will search HDD for certain file extensions. Once it searches it displays its results in a textbox. Now there are a couple of variables Like OS version, Secondary Partitions, and Profiles locations (all Windows). The user of this app will run this program to do a search on certain file extensions but also it will need to copy everything under the profile directory. Once it has run its search and the list of files found appear in the textbox the user should be able to select which files he/she would like to transfer up to a server. On the server a folder containing the Network Name of the computer should be created with the files that were selected to be transferred.

    I have started some of the app but alot of functionality is missing like how to transfer and search, and also how to get the network name of the pc:

    Thanks


    Private Sub cmdSearch_Click()
    Dim netid As String
    Dim FE As String
    Dim Profile As String
    Dim Store As String
    Dim Parlet As String
    Dim Partition As String
    Dim OS As String
    Dim SearchResults As String
    FE = "*.dbt, *.fds, *.pst, *.pab, *.xls, *.doc, *.mdb, *.dbf, *.ppt, *.tpm, *.msg, *.zbd, *.z20, *bookmark*"
    netid =
    OS = txtOS.Text
    Parlet = txtParlet.Text
    Partition = txtPartition.Text
    If OS = "NT" Then
    Profile = "C:\WINNT\Profiles"
    Else: Profile = "C:\Documents and Settings"

    End Sub
    Last edited by jora; Apr 21st, 2003 at 08:03 PM.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Why not create and shell a batch file to do a DOS search and
    output the results to a textfile. Then readin the textfile contents
    into a listview and let the user select the files to transfer over to
    the server?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2002
    Posts
    55

    Only thing is

    The only thing I can see a problem with is the current system in place runs a batch file. This exe the batch file calls misses 3/4 of those file extensions.

    Im up for anything that works do you possibly have a sample of how to do the search of the harddrive/partition, and transfer of the selected files?

    Thanks

  4. #4
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803
    Sometimes it's good to do a search before you post...

    I've replyed to someone else a while ago with simmilar problem
    http://vbforums.com/showthread.php?s=&threadid=234853

  5. #5

    Thread Starter
    Member
    Join Date
    Oct 2002
    Posts
    55

    Selecting the files and writing to server

    Okay thank you...
    What about selecting the files that this search pulls up then writing those files to a server.

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Here you go. My suggestion is to either get each extension
    separately or bring it all in and filter upon display in vb.
    It depends upon the size of the drive, but this goes quite fast.
    Code:
    'Code for the batch file.
    '%1 is the first parameter passed in.
    @echo off
    Dir %1 /s /a > C:\SearchResults.txt
    Then vb code to execute the batch.
    You need one form, one textbox (Text1), one command button (Command1).

    You will need to do better error trapping though.
    You will get the picture.
    Perhaps replacing the textbox with a drive listbox and a
    multi select combobox for the extensions.
    Code:
    Option Explicit
    
    Private Sub Command1_Click()
        
        Dim lRetVal As Long
        Dim sSearch As String
        
        If InStr(2, Text1.Text, ":\", vbTextCompare) = 2 Then
            sSearch = Trim(Text1.Text & "")
            lRetVal = Shell("C:\Search.bat " & sSearch, vbNormalFocus)
            
            If lRetVal > 0 Then
                MsgBox "Sucessful search", vbOKOnly + vbInformation
            Else
                MsgBox "Search Failed!", vbOKOnly + vbCritical
            End If
        Else
            MsgBox "Incorrect format!", vbOKOnly + vbInformation
        End If
        
    End Sub
    This will do a fast DOS search and pump the results into SearchResults.txt
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Member
    Join Date
    Oct 2002
    Posts
    55

    Just reading the code

    Thanks for the assistance in this. I read the code and basically I have to store this batch file on the drive of every computer I have to do this to? Its alot of computers attatched to this network. Basically if im reading correctly, the individual will put the file extension they want to search into the text box then click the command button? Every time I tried to put an extension in the text box it keeps giving me the error Incorrect format.

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Enter in the textbox - "C:\*.txt"
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9

    Thread Starter
    Member
    Join Date
    Oct 2002
    Posts
    55

    Now once this search is completed

    Once the search is done and the user selects the files he/she wants to move to the server...How would you go about storing those certain files to a server with the name \\Server1\Migration$\NAME OF COMPU SYSTEM FILES WERE STORED ON.

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    If you are using something like a listview to allow the users to
    select the files, then just loop through the listview (or other
    control) and perform a move of the files in the list.
    Code:
    FileMove (C:\File1.txt, "\\Server1\Migration$\NAME OF COMPU SYSTEM FILES WERE STORED ON")
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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