-
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
-
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