Newsgroup: it.comp.lang.visual-basic
Titolo: Reading CDROM contents

Greetings All,
I'm new to visual basic programming world. My CD-ROM contains some
files and
the files are stored in directories. For and example
dir1
 |
  ------> File1
          File2
          File3
          File2
          File1
dir2
 |
  ------> File4
          File5
What i would like to achive is that, using visual basic program, i
would like
to scan the CD, get the files of each directory and produce a list as
shown
below
   scan_file.txt
     Directory       File Name       Total
   --------------------------------------
     dir1            File1           2
                     File2           2
                     File3           1
 
     dir2            File4           1
                     File5           1
                                  ------
                            Total    7        
How could i achive the above using visual basic, is there any example
or code that i could use as a reference ? Please help!!
Thanks
Uthuras

 Greetings All,
For find cd-rom letter use this
Option Explicit
    Private Declare Function GetDriveType Lib "kernel32" Alias _
            "GetDriveTypeA" (ByVal sDrive As String) As Long
    Private Function DriveType(sDrive As String) As String
        Dim sDriveName As String
        Const DRIVE_TYPE_UNDETERMINED = 0
        Const DRIVE_ROOT_NOT_EXIST = 1
        Const DRIVE_REMOVABLE = 2
        Const DRIVE_FIXED = 3
        Const DRIVE_REMOTE = 4
        Const DRIVE_CDROM = 5
        Const DRIVE_RAMDISK = 6
        sDriveName = GetDriveType(sDrive & ":\")
        Select Case sDriveName
            Case DRIVE_TYPE_UNDTERMINED
                DriveType = "has not been recognized"
            Case DRIVE_ROOT_NOT_EXIST
                DriveType = "specified doesn't exist"
            Case DRIVE_CDROM
                DriveType = "is a CD-ROM drive."
            Case DRIVE_FIXED
                DriveType = "cannot be removed I.E. Hard Disk"
            Case DRIVE_RAMDISK
                DriveType = "is a RAM disk."
            Case DRIVE_REMOTE
                DriveType = "is a remote I.E Network drive."
            Case DRIVE_REMOVABLE
                DriveType = "can be removed I.E. Floppy Disk."
        End Select
   End Function
   Private Sub Drive1_Change()
       MsgBox "Drive Type: " &DriveType(Left(Drive1.Drive, 1))
   End Sub
For scan directory, subdirectory and file I hope this code help you.
In a Form (with a command button named "Command1)
Option Explicit
Private Directory(0 To 10000) As utDirectory 'livello e percorso
Private Sub trovadir(path As String, Livello As Integer)
On Error GoTo GestioneErrori
Dim MyDir As String
Dim Sottolivelli As Boolean
Dim n As Long
Dim i As Long
    MyDir = Dir(path, vbNormal + vbDirectory + vbHidden + vbArchive +
vbReadOnly + vbSystem + vbVolume) ' Recupera la prima voce.
    Do While MyDir <> ""   ' Avvia il ciclo.
        If (GetAttr(path & MyDir) And vbDirectory) = vbDirectory And MyDir
<> "." And MyDir <> ".." Then
            Debug.Print "Dir " & path & MyDir & " - " & Livello
            Directory(n).Livello = Livello
            Directory(n).Percorso = path & MyDir & "\"
            Sottolivelli = True
            n = n + 1
        End If
        MyDir = Dir
        DoEvents
    Loop
    If Sottolivelli = False Then Exit Sub
    i = 0
    Do While i <= 10000
        If Directory(i).Livello = Livello Then
            If Directory(i).Percorso > "" Then
                Call trovadir(Directory(i).Percorso, Livello + 1)
            End If
        End If
        i = i + 1
    DoEvents
    Loop
GestioneErrori:
    Select Case Err.Number
        Case Is = 5
            MyDir = Dir
            Resume
    End Select
End Sub
Private Sub Command1_Click()
Call trovadir("c:\", 0)
End Sub
In a module (.bas)
Option Explicit
Type utDirectory
    Percorso As String
    Livello As Integer
End Type
-- 
Le persone non sono il proprio comportamento: devi sempre andare oltre,
essere flessibile, capire il punto di vista degli altri, interpretarne i
comportamenti ed intuirne le esigenze.
Per rispondere in privato elimina
dall'indirizzo "togliquesto"
MasterDavidex
David Ruscelli