PC Review


Reply
Thread Tools Rate Thread

detect CF card

 
 
cfyam
Guest
Posts: n/a
 
      28th Nov 2003
How can I detect CF card or SD card is exist in PDA Device?


 
Reply With Quote
 
 
 
 
CottonTech Pty Ltd
Guest
Posts: n/a
 
      28th Nov 2003

>-----Original Message-----
>How can I detect CF card or SD card is exist in PDA

Device?
>

I use a simple function using the Directory keyword
(probably smoother ways but this works. Written in C#:

using System;
using System.IO;

private void AssumeStorage()
{ // Tests for \Storage Card and \Flash File Store,
bool b = false;
b=Directory.Exists("\\Storage Card");
if (b)
// Handle existance of storage card"
else
b=Directory.Exists("\\Flash File Store");
if (b)
{
// Handle existance of Flash File Store"
}
else
{
// Handle no CF storage
}
}
 
Reply With Quote
 
Rick Winscot
Guest
Posts: n/a
 
      28th Nov 2003
You should be careful with assumptions... as each manufacturer will
determine what these 'defaults' will be. I have found it far more reliable
to present the user with a file dialog that asks them to point to file store
on their device. This provides the best results for all hardware, all
potential storage locations and is user proof...

Rick Winscot
www.zyche.com


"CottonTech Pty Ltd" <(E-Mail Removed)> wrote in message
news:049701c3b551$64d49e20$(E-Mail Removed)...
>
> >-----Original Message-----
> >How can I detect CF card or SD card is exist in PDA

> Device?
> >

> I use a simple function using the Directory keyword
> (probably smoother ways but this works. Written in C#:
>
> using System;
> using System.IO;
>
> private void AssumeStorage()
> { // Tests for \Storage Card and \Flash File Store,
> bool b = false;
> b=Directory.Exists("\\Storage Card");
> if (b)
> // Handle existance of storage card"
> else
> b=Directory.Exists("\\Flash File Store");
> if (b)
> {
> // Handle existance of Flash File Store"
> }
> else
> {
> // Handle no CF storage
> }
> }



 
Reply With Quote
 
Roberto M. Oliva
Guest
Posts: n/a
 
      28th Nov 2003

As Rick said you should be aware that the name of the storage card may
change from device to device and from country to country.
What I've done is to use System.IO.Directory to read all the directories
contained on the root folder, and then P/Invoke: GetFileInformationByHandle
to see if the volume number is different from zero.

Hope this helps
Roberto



"CottonTech Pty Ltd" <(E-Mail Removed)> wrote in message
news:049701c3b551$64d49e20$(E-Mail Removed)...
>
> >-----Original Message-----
> >How can I detect CF card or SD card is exist in PDA

> Device?
> >

> I use a simple function using the Directory keyword
> (probably smoother ways but this works. Written in C#:
>
> using System;
> using System.IO;
>
> private void AssumeStorage()
> { // Tests for \Storage Card and \Flash File Store,
> bool b = false;
> b=Directory.Exists("\\Storage Card");
> if (b)
> // Handle existance of storage card"
> else
> b=Directory.Exists("\\Flash File Store");
> if (b)
> {
> // Handle existance of Flash File Store"
> }
> else
> {
> // Handle no CF storage
> }
> }



 
Reply With Quote
 
Christian Schwarz
Guest
Posts: n/a
 
      28th Nov 2003
cfyam, you shouldn't check the existance of a certain directory.

I haven't tried it so far, but maybe you could use functions
FindFirstStore() and FindNextStore() to gather STORAGEDEVICEINFO structures
and check dwDeviceType field for STORAGE_DEVICE_TYPE_PCCARD and
STORAGE_DEVICE_TYPE_CFCARD ? Maybe this structure (or PARTINFO structure)
contains even a field which holds the mount point ...

Christian


 
Reply With Quote
 
Peter Foot [MVP]
Guest
Posts: n/a
 
      28th Nov 2003
Each device type can use different names for storage cards and they can also
be localised into numerous languages so this approach will only work on
specific devices.

A better approach (no P/Invokes required) is to enumerate all the top level
folders which have the Directory and Temporary. Alex Feinman produced a
useful code sample to do this here:-
http://www.opennetcf.org/forums/topic.asp?TOPIC_ID=432

Peter

--
Peter Foot
Windows Embedded MVP
OpenNETCF.org Senior Advisor
www.inthehand.com | www.opennetcf.org

"CottonTech Pty Ltd" <(E-Mail Removed)> wrote in message
news:049701c3b551$64d49e20$(E-Mail Removed)...
>
> >-----Original Message-----
> >How can I detect CF card or SD card is exist in PDA

> Device?
> >

> I use a simple function using the Directory keyword
> (probably smoother ways but this works. Written in C#:
>
> using System;
> using System.IO;
>
> private void AssumeStorage()
> { // Tests for \Storage Card and \Flash File Store,
> bool b = false;
> b=Directory.Exists("\\Storage Card");
> if (b)
> // Handle existance of storage card"
> else
> b=Directory.Exists("\\Flash File Store");
> if (b)
> {
> // Handle existance of Flash File Store"
> }
> else
> {
> // Handle no CF storage
> }
> }



 
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
Can I detect when a flash card (SD or CF) is inserted into my card reader Tim Kelley Microsoft C# .NET 0 20th Nov 2007 02:07 PM
laptop doesn't detect LAN card (ethernet card) =?Utf-8?B?dmVvbA==?= Windows XP Networking 4 27th Aug 2006 03:26 AM
Cannot detect network card in PC card slot =?Utf-8?B?UGV0ZQ==?= Windows XP Help 1 7th Jun 2006 01:32 AM
auto detect not working when i insert flash card in card reader !! =?Utf-8?B?dmF1Z2hhbg==?= Windows XP Help 0 22nd Jul 2004 10:39 AM
How can i detect my sound card? =?Utf-8?B?QW5kcmUn?= Windows XP Help 4 31st Mar 2004 04:51 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:40 AM.