473,404 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Drive type

M K
I am looping through the drives and only want to process those that are
harddrives and not CD, floppy, dvd etc. What method(if any) or code do I
use?

What I am trying accomplish is to search for a certain type (i.e. *.bat,
*.ico etc) on every harddrive and return the name and path
(also a small graphic if its a graphic type object - ico, bmp etc)

Here is my code so far... Trying to figure out what to put in place of the
XXXXXXXXXX

If you have a better suggestion please feel free to let me know.

Dim strDrives As String()

Dim strThisDrive As String

Dim strThisDir As String

Dim strThisFile As String

Dim myFile As New StreamWriter("lsBMPImages.txt")

'get list of drives

strDrives = GetLogicalDrives()

'loop through each drive

For Each strThisDrive In strDrives

'loop through each directory

For Each strThisDir In GetDirectories(strThisDrive)

'get list of files - ONLY drive folders (no CD, floppy etc drives)

'XXXXXXXXXXXX

For Each strThisFile In GetFiles(strThisDir)

'look for the image we want

If strThisFile.EndsWith(strImage) Then

myFile.WriteLine(strThisFile & vbTab)

End If

Next

Next

Next

myFile.Close()
Nov 21 '05 #1
5 1028
"M K" <sk*******@yahoo.com> schrieb:
I am looping through the drives and only want to process those that are
harddrives and not CD, floppy, dvd etc. What method(if any) or code do I
use?


<URL:http://dotnet.mvps.org/dotnet/faqs/?id=setcddoorstatus&lang=en>
<URL:http://dotnet.mvps.org/dotnet/code/filesystem/#DriveType>

..NET 2.0 will contain the class 'System.IO.DriveInfo' which has a property
'DriveType'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2
Till then, you can use the GetDriveType API function via P/Interop

-Atul, Sky Software http://www.ssware.com
Shell MegaPack For ActiveX & .Net - Windows Explorer Like Shell UI Controls

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:Ot**************@TK2MSFTNGP09.phx.gbl...
"M K" <sk*******@yahoo.com> schrieb:
I am looping through the drives and only want to process those that are
harddrives and not CD, floppy, dvd etc. What method(if any) or code do I
use?


<URL:http://dotnet.mvps.org/dotnet/faqs/?id=setcddoorstatus&lang=en>
<URL:http://dotnet.mvps.org/dotnet/code/filesystem/#DriveType>

.NET 2.0 will contain the class 'System.IO.DriveInfo' which has a property
'DriveType'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3
"Bob S" <staheli.bobatgmaildotcom> schrieb:
Till then, you can use the GetDriveType API function via P/Interop


That's what I recommended...

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #4
M K
Thanks .. that did the trick

not sure what P/Interop means as some of you developers seem to think
everyone knows as much
as you do but i've leared to live with that :)

Thanks again,
Mark

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
"Bob S" <staheli.bobatgmaildotcom> schrieb:
Till then, you can use the GetDriveType API function via P/Interop


That's what I recommended...

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #5
"M K" <sk*******@yahoo.com> schrieb:
not sure what P/Interop means


There is a huge chapter about platform invoke in the documentation :-).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Mayer | last post by:
Hello: I'm running python under cygwin and need to find the drive letter. Cygwin has a way of calling my drives by a name relative to the Cygwin directory, so I get things like /home/user rather...
3
by: Robert Tarantino | last post by:
Hello, I am trying to find a way to create a scheduled task or service that will copy my local profile folders under "Documents and settings" to a network drive. This would allow me to restore...
2
by: Al Sav | last post by:
Hi, After enumerating the logical drives, using GetLogicalDrives, I need to know the Drive Types, ie. Floppy or Network. Is it possible in C# to do this? Thanks in advance. Alwin S.
4
by: Robert Tarantino | last post by:
Hello, I am trying to find a way to create a scheduled task or service that will copy my local profile folders under "Documents and settings" to a network drive. This would allow me to restore...
23
by: Rotsey | last post by:
Hi, I am writing an app that scans hard drives and logs info about every fine on the drive. The first iteration of my code used a class and a generic list to store the data and rhis took...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.