yaniv Posted June 12, 2007 Posted June 12, 2007 i need to build an application that find PDF's of news paper aditions. the PDF should stay on the installation CD. what is the right way to find/ keep the right path in "any machine"? how can i get the right leeter that any user use for his CD drive... thanks Quote
Eduardo Lorenzo Posted June 13, 2007 Posted June 13, 2007 My.Computer.FileSystem.Drives will give you a collection of the machine's drives Quote
Administrators PlausiblyDamp Posted June 13, 2007 Administrators Posted June 13, 2007 If My.Computer.FileSystem.Drives(0).DriveType = IO.DriveType.CDRom Then End If sometimes the intellisense is a bit quicker than asking ;) Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
penfold69 Posted June 13, 2007 Posted June 13, 2007 This method can fail if there are multiple CD drives in a machine. When would be a good idea is to scan each drive, and look for the presence of a particular file in the root of that drive. This should ensure that you can uniquely identify *your* CD. It also handles the fact that your user removed your CD and replaced it with "Goldie Looking Chain's Greatest Hit". P. Quote
penfold69 Posted June 13, 2007 Posted June 13, 2007 concept code, untested. Dim myDrive As System.IO.DriveInfo = Nothing For Each d As System.IO.DriveInfo In My.Computer.FileSystem.Drives If d.DriveType = IO.DriveType.CDRom Then Dim di As System.IO.DirectoryInfo = d.RootDirectory If di.GetFiles("MyUniqueFileName.txt").Length > 0 Then myDrive = d Exit For End If End If Next If myDrive IsNot Nothing Then ' Yay! I found the right CD drive, and it contains my CD DoSomeStuff() Else MsgBox("Please insert the application CD-ROM into one of your drives") End If Quote
yaniv Posted June 13, 2007 Author Posted June 13, 2007 thanks all, it is really what i needed. good people you are.:D Quote
Administrators PlausiblyDamp Posted June 13, 2007 Administrators Posted June 13, 2007 (edited) This method can fail if there are multiple CD drives in a machine. When would be a good idea is to scan each drive, and look for the presence of a particular file in the root of that drive. This should ensure that you can uniquely identify *your* CD. It also handles the fact that your user removed your CD and replaced it with "Goldie Looking Chain's Greatest Hit". P. The code I posted was a quick example to point him in the right direction - it wasn't meant to be a complete working solution. Edited August 31, 2007 by PlausiblyDamp Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.