Friday, October 12, 2007

Getting a List of Storage Card Directories for Smartphone and Windows Mobile

There are lots of example of getting a list of Storage Card directories for Windows Mobile and Smartphone out there. He is one that I have cobbled together from the other example in VB.NET.

Other references that include C# examples are:

http://msdn2.microsoft.com/en-us/library/aa446567.aspx

http://www.opennetcf.org/forums/topic.asp?TOPIC_ID=432

Imports System.IO

Public Function GetStorageCardNames() As String()

Try

Dim attrStorageCard As FileAttributes = FileAttributes.Directory Or FileAttributes.Temporary
Dim scards As New ArrayList()
Dim rootDir As New DirectoryInfo("\")

For Each di As DirectoryInfo In rootDir.GetDirectories()

If (di.Attributes And attrStorageCard) = attrStorageCard Then
scards.Add(di.Name)
End If

Next

Return CType(scards.ToArray(GetType(String)), String())

Catch ex As Exception

Return Nothing

End Try

End Function

No comments: