Results 1 to 2 of 2

Thread: To get a file from the CD from VB (Urgent)

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2000
    Location
    Minneapolis
    Posts
    42
    Hi,

    Can i know the VB code to do the following:
    *****
    I have a file called "X.txt" in the CD rom(The drive name may be "D" or "V" or "X" on different computers.My program
    needs to run on different PC's)
    How can i get the file "X.txt" file from the CD rom drive irrespective of the CD Rom drive name("D" or "V" or "X").
    ****
    Any code with Windows API's will also be helpfull.
    Please reply soon
    Thanks,
    Srini

  2. #2
    Hyperactive Member marnitzg's Avatar
    Join Date
    Oct 2000
    Location
    South Africa
    Posts
    372

    Quick code

    Here's some quick code that should help you. It will find the CDRom with the file so you can have more than 1 CDRom drive as well.
    Code:
    Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" _
      (ByVal nDrive As String) As Long
    
    Private Sub Form_Load()
    Dim X As Integer
    
    For X = 68 To 91
         If GetDriveType(Chr(X) & ":\") = 5 Then
               If Dir(Chr(X) & ":\X.txt") <> "" Then
                    MsgBox "Found the file!"
                    Exit For
               End If 
         End If
    Next
    End Sub

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