English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

It is hard for me to.... because i'm a beginner, no book yet to refer...

Help me solving my problem, I wanna know what command use for opening a folder on a removable drive. As we know, the removable drive letter will change for difference PC/notebook/Laptop, how do i do it??

this is my situation, i make an application, an put it in a removable drive,i write an autorun.inf so everytime user click the removable drive, the application will run. after user enter password and username, and get it right, a MsgBox("Hi..") will appear and user click OK then the removable drive will open it contents.

but my problem is, i dont know what comman to use to open the removable drive.

i've tried

Dim MyPath as String
MyPath = CurDir()
File.Open(MyPath)

it doesnt open the drive letter. Help me please

2007-02-14 11:59:59 · 5 answers · asked by anashah85 1 in Computers & Internet Programming & Design

5 answers

Here is some VB express code which will identify all drives install on a PC.

You can Identify your particular Flash drive with a specific Volume Label and ensure that it is connected to the PC and extract its assigned letter.

This should get you going:


Dim drv As IO.DriveInfo

For Each drv In My.Computer.FileSystem.Drives
Try
Debug.WriteLine(drv.DriveType & " " & drv.Name & " " & drv.VolumeLabel)
If drv.DriveType = IO.DriveType.Removable Then
Debug.WriteLine(drv.VolumeLabel)
End If
Catch ex As Exception
Debug.WriteLine(drv.Name & " is not available as it has no media in it. Volume Lable is unavailable")
End Try
Next

2007-02-14 13:55:57 · answer #1 · answered by MarkG 7 · 0 0

curdir() returns the current directory, like "e:\fu\bar" . Try

Filesystem.Getfiles(left(curdir(), 3)

whichshould get a list of the files in "e:\" which is probably what you want. Ya can't open a directory with file.open anyway (iirc).

2007-02-14 12:39:49 · answer #2 · answered by Meg W 5 · 0 0

According to MSDN, you should be using My.Computer.FileSystem.CurrentDirectory Property

CurDir() won't work since it only returns the most recently used current directory, and each drive has its own current directory.

For VB6, you may need
http://www.freevbcode.com/ShowCode.Asp?ID=878

2007-02-14 12:40:57 · answer #3 · answered by Kasey C 7 · 0 0

hmm I did some searching and found the following for you..

Check Removable Drives for Presence of Disk or CD
http://www.freevbcode.com/ShowCode.Asp?ID=1681

Detecting the insertion of smartmedia / removable drives
http://www.vbcity.com/forums/topic.asp?tid=11081&highlight=USB

good luck

2007-02-14 13:14:04 · answer #4 · answered by EddieS 2 · 0 0

not sure what version of vb you're using.

if it's vb 8 , search the " my namespace " which is new to vb8 making the accessing of drives and much more easier.

Navigate your projects with "my"
http://msdn.microsoft.com//msdnmag/issues/04/05/visualbasic2005/default.aspx

2007-02-14 12:45:58 · answer #5 · answered by ? 3 · 0 0

fedest.com, questions and answers