davidh Posted October 4, 2004 Posted October 4, 2004 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 Quote
TamuTamu Posted October 4, 2004 Posted October 4, 2004 It should be @"\Storage Card" or "\\Storage Card" It wont work on the emulator because the emulator doesn't have a storage card. Quote
davidh Posted October 5, 2004 Author Posted October 5, 2004 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. Quote
davidh Posted October 5, 2004 Author Posted October 5, 2004 Actually I notice it now falls over on the next line where I'm trying to call di.GetDirectories(). Quote
Administrators PlausiblyDamp Posted October 5, 2004 Administrators Posted October 5, 2004 Using the @ symbol or the \\ notation is only required in C# where \ is used to denote escape sequences, under VB the \ character doesn't have any special meaning. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
davidh Posted October 5, 2004 Author Posted October 5, 2004 Ok, taken the \\ out and replaced with \ and it all works fine now. Thanks for your help. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.