PC Review


Reply
Thread Tools Rate Thread

Directory.GetFiles failure

 
 
Andrew Boswell
Guest
Posts: n/a
 
      8th Nov 2003
Hi,

On my Pocket PC, the call to Directory.GetFiles(folderPath) fails with "No
such directory" exception if folderPath ends in a space, even though the
folderPath is valid. It shows up OK in File Explorer.

DirectoryInfo.GetFiles also fails in the same way.

Any ideas for a workaround?

Thanks,
Andrew
 
Reply With Quote
 
 
 
 
William Ryan
Guest
Posts: n/a
 
      8th Nov 2003
GetFiles does work, are you sure you are giving it a valid directory?

For instance, try a Debug.Assert("SomeDirectory);
//now do the Directory.GetFiles("SomeDirectory"); //making sure the some
directory is the exact same thing.

You may even want to use a string or constant like sooo

string s = @"Storage Card\"

Debug.Assert(s);
string[] myFiles = Directory.GetFiles(s);

If you are using C#, make sure you use the @ and if not, make sure you
double escape the \\.

HTH,

Bill
"Andrew Boswell" <(E-Mail Removed)> wrote in message
news:Xns942DDDF099DACandrewboswelldemonco@207.46.248.16...
> Hi,
>
> On my Pocket PC, the call to Directory.GetFiles(folderPath) fails with "No
> such directory" exception if folderPath ends in a space, even though the
> folderPath is valid. It shows up OK in File Explorer.
>
> DirectoryInfo.GetFiles also fails in the same way.
>
> Any ideas for a workaround?
>
> Thanks,
> Andrew



 
Reply With Quote
 
Andrew Boswell
Guest
Posts: n/a
 
      9th Nov 2003
Hi Bill,

Yes, all that is OK. My program works fine until I create a directory
(using file explorer) that has a space at the end of its name, then
GetFiles fails.

I've now written a workaround using native calls to FindFirstFile and
FindNextFile.

Thanks for your help.

Andrew



"William Ryan" <(E-Mail Removed)> wrote in
news:#(E-Mail Removed):

> GetFiles does work, are you sure you are giving it a valid directory?
>
> For instance, try a Debug.Assert("SomeDirectory);
> //now do the Directory.GetFiles("SomeDirectory"); //making sure the
> some directory is the exact same thing.
>
> You may even want to use a string or constant like sooo
>
> string s = @"Storage Card\"
>
> Debug.Assert(s);
> string[] myFiles = Directory.GetFiles(s);
>
> If you are using C#, make sure you use the @ and if not, make sure you
> double escape the \\.
>
> HTH,
>
> Bill
> "Andrew Boswell" <(E-Mail Removed)> wrote in message
> news:Xns942DDDF099DACandrewboswelldemonco@207.46.248.16...
>> Hi,
>>
>> On my Pocket PC, the call to Directory.GetFiles(folderPath) fails
>> with "No such directory" exception if folderPath ends in a space,
>> even though the folderPath is valid. It shows up OK in File Explorer.
>>
>> DirectoryInfo.GetFiles also fails in the same way.
>>
>> Any ideas for a workaround?
>>
>> Thanks,
>> Andrew

>
>
>


 
Reply With Quote
 
William Ryan
Guest
Posts: n/a
 
      9th Nov 2003
I've not tried it with Directories that end with a Space -- it will work
with "Storage Card" for instance. I'm going to give it a try though, b/c if
you end up with a Space at the end, it'd defintely make your program more
robust if you checked for a space if it will cause a problem. Definitely
something I want to check out.

Cheers,

Bill
"Andrew Boswell" <(E-Mail Removed)> wrote in message
news:Xns942E2E31D4andrewboswelldemonco@207.46.248.16...
> Hi Bill,
>
> Yes, all that is OK. My program works fine until I create a directory
> (using file explorer) that has a space at the end of its name, then
> GetFiles fails.
>
> I've now written a workaround using native calls to FindFirstFile and
> FindNextFile.
>
> Thanks for your help.
>
> Andrew
>
>
>
> "William Ryan" <(E-Mail Removed)> wrote in
> news:#(E-Mail Removed):
>
> > GetFiles does work, are you sure you are giving it a valid directory?
> >
> > For instance, try a Debug.Assert("SomeDirectory);
> > //now do the Directory.GetFiles("SomeDirectory"); //making sure the
> > some directory is the exact same thing.
> >
> > You may even want to use a string or constant like sooo
> >
> > string s = @"Storage Card\"
> >
> > Debug.Assert(s);
> > string[] myFiles = Directory.GetFiles(s);
> >
> > If you are using C#, make sure you use the @ and if not, make sure you
> > double escape the \\.
> >
> > HTH,
> >
> > Bill
> > "Andrew Boswell" <(E-Mail Removed)> wrote in message
> > news:Xns942DDDF099DACandrewboswelldemonco@207.46.248.16...
> >> Hi,
> >>
> >> On my Pocket PC, the call to Directory.GetFiles(folderPath) fails
> >> with "No such directory" exception if folderPath ends in a space,
> >> even though the folderPath is valid. It shows up OK in File Explorer.
> >>
> >> DirectoryInfo.GetFiles also fails in the same way.
> >>
> >> Any ideas for a workaround?
> >>
> >> Thanks,
> >> Andrew

> >
> >
> >

>



 
Reply With Quote
 
Andrew Boswell
Guest
Posts: n/a
 
      10th Nov 2003
Hi Bill,

Thanks. The problem is that if one of my users has a folder on their
Pocket Pc whose name ends with a space, I won't be able to process it
properly.

Thanks again,
Andrew


"William Ryan" <(E-Mail Removed)> wrote in
news:#$(E-Mail Removed):

> I've not tried it with Directories that end with a Space -- it will
> work with "Storage Card" for instance. I'm going to give it a try
> though, b/c if you end up with a Space at the end, it'd defintely make
> your program more robust if you checked for a space if it will cause a
> problem. Definitely something I want to check out.
>
> Cheers,
>
> Bill
> "Andrew Boswell" <(E-Mail Removed)> wrote in message
> news:Xns942E2E31D4andrewboswelldemonco@207.46.248.16...
>> Hi Bill,
>>
>> Yes, all that is OK. My program works fine until I create a directory
>> (using file explorer) that has a space at the end of its name, then
>> GetFiles fails.
>>
>> I've now written a workaround using native calls to FindFirstFile and
>> FindNextFile.
>>
>> Thanks for your help.
>>
>> Andrew
>>

 
Reply With Quote
 
Alex Feinman [MVP]
Guest
Posts: n/a
 
      10th Nov 2003
I noticed that if I try to create a directory with a trailing space using
File Explorer, it complains. Renaming a directory and putting a trailing
space at the end succeeds but seems to get cleared upon refresh. Something
is fishy there

"Andrew Boswell" <(E-Mail Removed)> wrote in message
news:Xns942F74E574Candrewboswelldemonco@207.46.248.16...
> Hi Bill,
>
> Thanks. The problem is that if one of my users has a folder on their
> Pocket Pc whose name ends with a space, I won't be able to process it
> properly.
>
> Thanks again,
> Andrew
>
>
> "William Ryan" <(E-Mail Removed)> wrote in
> news:#$(E-Mail Removed):
>
> > I've not tried it with Directories that end with a Space -- it will
> > work with "Storage Card" for instance. I'm going to give it a try
> > though, b/c if you end up with a Space at the end, it'd defintely make
> > your program more robust if you checked for a space if it will cause a
> > problem. Definitely something I want to check out.
> >
> > Cheers,
> >
> > Bill
> > "Andrew Boswell" <(E-Mail Removed)> wrote in message
> > news:Xns942E2E31D4andrewboswelldemonco@207.46.248.16...
> >> Hi Bill,
> >>
> >> Yes, all that is OK. My program works fine until I create a directory
> >> (using file explorer) that has a space at the end of its name, then
> >> GetFiles fails.
> >>
> >> I've now written a workaround using native calls to FindFirstFile and
> >> FindNextFile.
> >>
> >> Thanks for your help.
> >>
> >> Andrew
> >>



 
Reply With Quote
 
Andrew Boswell
Guest
Posts: n/a
 
      10th Nov 2003
Hi Alex,

Yes File Explorer works in the way that you describe, but Resco File
Explorer allows a blank space to be added at the end of a folder name
and it stays there.

Regards,
Andrew

"Alex Feinman [MVP]" <(E-Mail Removed)> wrote in
news:O9Kfk$(E-Mail Removed):

> I noticed that if I try to create a directory with a trailing space
> using File Explorer, it complains. Renaming a directory and putting a
> trailing space at the end succeeds but seems to get cleared upon
> refresh. Something is fishy there
>
> "Andrew Boswell" <(E-Mail Removed)> wrote in message
> news:Xns942F74E574Candrewboswelldemonco@207.46.248.16...
>> Hi Bill,
>>
>> Thanks. The problem is that if one of my users has a folder on their
>> Pocket Pc whose name ends with a space, I won't be able to process it
>> properly.
>>
>> Thanks again,
>> Andrew
>>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Directory.GetFiles() / DirectoryInfo.GetFiles() on a remote server =?Utf-8?B?RGFuaWVsIENvcnLDqmE=?= Microsoft ASP .NET 2 24th Mar 2007 06:59 PM
Directory.GetFiles() =?Utf-8?B?U2FtZWVyIEd1cHRh?= Microsoft Dot NET Framework 2 6th Oct 2006 03:54 PM
Directory.GetFiles S. Han Microsoft C# .NET 3 20th Jan 2005 10:24 AM
Directory.GetFiles help Michelle Microsoft C# .NET 0 9th Nov 2003 04:43 AM
Directory.GetFiles brian Microsoft VB .NET 1 26th Sep 2003 04:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:13 AM.