com >> Application for parsing the contents of a removable drive

by cG11ZA » Fri, 12 May 2006 23:02:02 GMT

Hi,

I am new to VB and I am wondering if you any suggestions for what I am
trying to do. Basically, I need to create a Windows Application or ActiveX
object, which will look for any removable drives on the computer and in those
drives it will look for which folder has the Info.ini file. Whichever folder
has this file, I want to parse this file, and match the information presetn
in this file to the database.

How to accomplish this? All ideas/ help is welcome.

Thanks
--
pmud


com >> Application for parsing the contents of a removable drive

by MikeD » Sat, 13 May 2006 02:38:40 GMT







What part of this do you need help with? Finding the removable drives?
Searching them for this Info.ini file? Reading the Info.ini file? Matching
it to the database (whatever that means)?

You need to be specific on exactly what you need help with. Also, you need
to be clear about whether you want this to be a standalone application, or
an ActiveX DLL or OCX that will be used by other applications.

As far as determining removable drives, first, use the
GetLogicalDriveStrings Win32 API function. You'll probably have to use WMI
to determine if the drive is removeable (and in fact, you may just want to
use WMI to get the drive letters). There is a GetDriveType Win32 API
function, but I don't think it'll tell you if the drive is removable (only
if the drive uses removable media). I assume you mean drives like an
external hard drive or flash drive.

--
Mike
Microsoft MVP Visual Basic




com >> Application for parsing the contents of a removable drive

by cG11ZA » Mon, 15 May 2006 21:06:02 GMT

Hi Mike,

I am sorry. I should have been more clear. I basically have the following
code. I think I will not worry about the removable drives for now.
Private Sub btnUpload_Click()

Dim intdrive As Integer
intdrive = drvChoose.ListIndex 'gets the index of the drive

Dim strdrive As String
strdrive = drvChoose.List(intdrive) 'gets the full name of the drive

Dim strDriveLetter As String
strDriveLetter = Mid(strdrive, 1, InStr(1, strdrive, ":")) 'gets the one
letter name of the drive

MsgBox ("The selected drive is" & strDriveLetter & "\")

If (Dir(strDriveLetter & "\PInfo.ini") = "PInfo.ini") Then
MsgBox ("The file exists in" & strDriveLetter)
Else
MsgBox ("The file DOES NOT exist in" & strDriveLetter)
End If

End Sub

Now, I want to look at all directories within the drive selected by the user
and look for the PInfo.ini file there rather than looking in the root drive;
i.e instead of
If (Dir(strDriveLetter & "\PInfo.ini") = "PInfo.ini") , I want to do
If (Dir(strDriveLetter &"\*\& "\PInfo.ini") = "PInfo.ini") so that the
program searches for PInfo.ini in a directory within that folder rather than
serching in the root folder.

Is there any function specified in VB to do this? Using * wildcard character
for a folder names doesnt work.

Thanks for your help.

--
pmud








Application for parsing the contents of a removable drive

by cG11ZA » Tue, 16 May 2006 03:48:01 GMT

i,

I used a workaround by making putting a directory list box and making it
invisible for the end user and then using this code:

Private Sub btnUpload_Click()
dirDirect.Path = drvChoose.Drive 'Displays the directories in the drive
chosen by the user.

Dim i As Integer
Dim SubDir As String

For i = 0 To dirDirect.ListCount - 1 ' For the no. of directories in the
drive loop through the contents
MsgBox (i)
SubDir = dirDirect.List(i)
MsgBox (SubDir)

If (Dir(SubDir & "\PInfo.ini") = "PInfo.ini") Then
MsgBox ("The file exists in " & SubDir)
intReadFile = FreeFile

Else
MsgBox ("The file DOES NOT exist in " & SubDir)
End If
Next

End Sub

Thanks
--
pmud


"pmud" wrote:



Similar Threads

1. Display only removable drives in Drive List Box - Visual Basic/VB

2. Code needs to be alerted that a removable disk drive's state

You can just start a thread the checks the drive status periodically then 
raises an event to notify your main thread or set the status appropriately.  
I don't think there is an event raised when a disk is removed or inserted.

"Just Me" wrote:

> I wonder if I wasn't clear as to what I need.
> Think of Windows Explorer like app showing
>   31/2 Floppy (A:)   {Not Ready}
> 
> If the floppy "ready" state changes I need to be notified so that the 
> display can be changed.
> 
> I could, for example, have a timer tick event periodically check the drive 
> but hope that is not the only way to do it.
> 
> Thanks
> 
> 
> "Dennis" < XXXX@XXXXX.COM > wrote in message 
> news: XXXX@XXXXX.COM ...
> > There is probably something that does this directly but I would consider
> > putting any reads/writes to any drive inside a try/catch/finally loop.  If
> > the file can't be written/read, an exception will be thrown that contains 
> > the
> > reason why (e.message).
> >
> > "Just Me" wrote:
> >
> >> I check to see if the Floppy drive is ready and display it's state.
> >>
> >> But if the user inserts or removes a floppy disk I need an event or
> >> Windproof
> >> message to cause the code to display the new state.
> >>
> >> Is the some way the code can be alerted to the fact that a removable disk
> >> drive's state changed?
> >>
> >>
> >>
> >> Thanks
> >>
> >>
> >>
> >> 
> 
> 
> 

3. Code needs to be alerted that a removable disk drive's state changed - VB.Net

4. How to remove Volume Name on removable drive?

Hi all,

I have an application that can use many different compact-flash cards as 
storage for different jobs the client is working on.  I have added a 
function to erase all files from a flash card, and that works fine.

But I would also like to be able to make the Volume Label on each flash card 
the job name its files belong to.  I can't work out how to either write the 
Volume Label to the cards, or to remove it when I erase them.   I did this 
in VB5 by using a Windows API call - surely VB.NET 2003 is smarter than 
that?

Anybody know the "right" way to do this in VB.NET?

Thanks 


5. Code needs to be alerted that a removable disk drive's state chan - VB.Net

6. Remap removable drive

on error resume next
Dim fso, WshShell
'*****************
Set fso = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
'***********************
drive_to_remap = "f:"     ' Change to your letter to change
Set d = fso.GetDrive(drive_to_remap)   'Check if the drive exist
If Err Then
        err.clear
else
        if d.DriveType = 1 then     ' 1 = removable drive
                'Create a Text file to call with diskpart(From XP) to
change the drive letter
                fso.createtextfile("c:\temp\diskpartscript.txt")
                set script_file =
fso.OpenTextFile("c:\temp\diskpartscript.txt",2,true)
                script_file.WriteLine "Select Volume " &
drive_to_remap
                script_file.WriteLine "Assign"
                script_file.WriteLine "Exit"
                wshshell.run "diskpart /s
c:\temp\diskpartscript.txt",1,1
        end if
end if

7. Script to share removable drive at boot up ?

8. Detecting a removable drive in VB6

Garry < XXXX@XXXXX.COM > schrieb im Beitrag
< XXXX@XXXXX.COM >...
> I need to know if a path is on a removable memory stick or drive.
> What API will give me this answer going back to possibly win ME.
> However, limited to Win 2K or XP will still give me a handle 

GetDriveType() works on all versions of Windows. Unfortunately I can't tell
you what it returns for a memory stick - but it should return
DRIVE_REMOVABLE, or, at least, not DRIVE_FIXED.

-- 
----------------------------------------------------------------------
THORSTEN ALBERS				        Universit Freiburg
                                                albers@
                                                       uni-freiburg.de
----------------------------------------------------------------------