Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

 

I'm trying to do a simple search of files of a certain type on a pocket pc. I pulled the code below off the internet but keep getting a DirectoryNotFoundException on the New DirectoryInfo(Directory) line. Although I've got "\Storage Card" on this example I've tried it with \Program Files and various other folders that are always there. It fails both on the emulator and on the device itself.

 

Any clues on what I'm doing wrong would be greatfully appreciated

 

Thanks

 

Dave

 

       Try
           Dim di As DirectoryInfo = New DirectoryInfo("\Storage Card")
           Dim dirs As DirectoryInfo() = di.GetDirectories()
           Dim s As String() = Directory.GetFiles("*.tga")
           ListBox1.Items.Add("Number of guides on storage card is " & s.GetLength(0))
           ListBox1.Items.Add("Number of directories on card is " & dirs.Length)

           Dim diNext As DirectoryInfo
           For Each diNext In dirs
               ListBox1.Items.Add("The number of guides in " & diNext.Name & " with is " & diNext.GetFiles("*.tga").Length)
           Next

       Catch ex As Exception
           MessageBox.Show("The process failed: " & ex.ToString())
       End Try

Posted
If I try @"\Storage Card" the project no longer compiles, it complains about an invalid character, and if I try "\\Storage Card", or "\\Program Files" on the emulator, the exception now changes to System.IO.IOException instead of the original DirectoryNotFoundException.

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...