Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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.

Posted

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

  • Administrators
Posted (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 by PlausiblyDamp

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...