Drive type

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • M K

    #1

    Drive type

    I am looping through the drives and only want to process those that are
    harddrives and not CD, floppy, dvd etc. What method(if any) or code do I
    use?

    What I am trying accomplish is to search for a certain type (i.e. *.bat,
    *.ico etc) on every harddrive and return the name and path
    (also a small graphic if its a graphic type object - ico, bmp etc)

    Here is my code so far... Trying to figure out what to put in place of the
    XXXXXXXXXX

    If you have a better suggestion please feel free to let me know.



    Dim strDrives As String()

    Dim strThisDrive As String

    Dim strThisDir As String

    Dim strThisFile As String

    Dim myFile As New StreamWriter("l sBMPImages.txt" )

    'get list of drives

    strDrives = GetLogicalDrive s()

    'loop through each drive

    For Each strThisDrive In strDrives

    'loop through each directory

    For Each strThisDir In GetDirectories( strThisDrive)

    'get list of files - ONLY drive folders (no CD, floppy etc drives)

    'XXXXXXXXXXXX

    For Each strThisFile In GetFiles(strThi sDir)

    'look for the image we want

    If strThisFile.End sWith(strImage) Then

    myFile.WriteLin e(strThisFile & vbTab)

    End If

    Next

    Next

    Next

    myFile.Close()


  • Herfried K. Wagner [MVP]

    #2
    Re: Drive type

    "M K" <ski_freak@yaho o.com> schrieb:[color=blue]
    >I am looping through the drives and only want to process those that are
    > harddrives and not CD, floppy, dvd etc. What method(if any) or code do I
    > use?[/color]

    <URL:http://dotnet.mvps.org/dotnet/faqs/?id=setcddoorst atus&lang=en>
    <URL:http://dotnet.mvps.org/dotnet/code/filesystem/#DriveType>

    ..NET 2.0 will contain the class 'System.IO.Driv eInfo' which has a property
    'DriveType'.

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://classicvb.org/petition/>

    Comment

    • Bob S

      #3
      Re: Drive type

      Till then, you can use the GetDriveType API function via P/Interop

      -Atul, Sky Software http://www.ssware.com
      Shell MegaPack For ActiveX & .Net - Windows Explorer Like Shell UI Controls



      "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
      news:Otg6TiarFH A.2064@TK2MSFTN GP09.phx.gbl...[color=blue]
      > "M K" <ski_freak@yaho o.com> schrieb:[color=green]
      >>I am looping through the drives and only want to process those that are
      >> harddrives and not CD, floppy, dvd etc. What method(if any) or code do I
      >> use?[/color]
      >
      > <URL:http://dotnet.mvps.org/dotnet/faqs/?id=setcddoorst atus&lang=en>
      > <URL:http://dotnet.mvps.org/dotnet/code/filesystem/#DriveType>
      >
      > .NET 2.0 will contain the class 'System.IO.Driv eInfo' which has a property
      > 'DriveType'.
      >
      > --
      > M S Herfried K. Wagner
      > M V P <URL:http://dotnet.mvps.org/>
      > V B <URL:http://classicvb.org/petition/>[/color]


      Comment

      • Herfried K. Wagner [MVP]

        #4
        Re: Drive type

        "Bob S" <staheli.bobatg maildotcom> schrieb:[color=blue]
        > Till then, you can use the GetDriveType API function via P/Interop[/color]

        That's what I recommended...

        --
        M S Herfried K. Wagner
        M V P <URL:http://dotnet.mvps.org/>
        V B <URL:http://classicvb.org/petition/>

        Comment

        • M K

          #5
          Re: Drive type

          Thanks .. that did the trick

          not sure what P/Interop means as some of you developers seem to think
          everyone knows as much
          as you do but i've leared to live with that :)

          Thanks again,
          Mark

          "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
          news:%23hP55Jir FHA.3884@TK2MSF TNGP11.phx.gbl. ..[color=blue]
          > "Bob S" <staheli.bobatg maildotcom> schrieb:[color=green]
          >> Till then, you can use the GetDriveType API function via P/Interop[/color]
          >
          > That's what I recommended...
          >
          > --
          > M S Herfried K. Wagner
          > M V P <URL:http://dotnet.mvps.org/>
          > V B <URL:http://classicvb.org/petition/>[/color]


          Comment

          • Herfried K. Wagner [MVP]

            #6
            Re: Drive type

            "M K" <ski_freak@yaho o.com> schrieb:[color=blue]
            > not sure what P/Interop means[/color]

            There is a huge chapter about platform invoke in the documentation :-).

            --
            M S Herfried K. Wagner
            M V P <URL:http://dotnet.mvps.org/>
            V B <URL:http://classicvb.org/petition/>

            Comment

            Working...