OpenNetCF: FileSystemWatcher on root directory

G

Guest

Hi All

Can I use FileSystemWatcher to monitor changes to the root directory of a memory card? I'm trying to detect insert/remove of memory card. Below is my snippet of code which does not seem to detect the event. Thanks in advance for your insights.

Ge
(e-mail address removed)
=============================================

// default to fals
IsFullFramework = false

#region FULL_FRAMEWOR
IsFullFramework = System.Environment.OSVersion.Platform != PlatformID.WinCE
#endregio

if (! IsFullFramework

string[] CFNames = StorageCard.GetStorageCardNames()
// IPaq has internal RAM card, first storage card is the external CF card
if (CFNames.Length < 2
MessageBox.Show("Please insert RAM Card", "Notice")
els
{
DirectoryInfo[] CFDirectoryList = StorageCard.GetStorageCards();
FileWatcher = new FileSystemWatcher(CFDirectoryList[0].FullName)
FileWatcher.Changed += new FileSystemEventHandler(fsw_Changed)
FileWatcher.Created += new FileSystemEventHandler(fsw_Changed)
FileWatcher.Deleted += new FileSystemEventHandler(fsw_Changed)
FileWatcher.EnableRaisingEvents = true
FileWatcher.IncludeSubdirectories = true



private void fsw_Changed(object sender, FileSystemEventArgs e

MessageBox.Show("Please insert RAM Card", "Notice")
 
A

Alex Yakhnin [MVP]

Can I use FileSystemWatcher to monitor changes to the root directory of a
memory card?

I haven't tried this and don't know if this is going to work. Probably not.
Take a look at this article for ideas on how to handle of the
insertion/removal of the storage card

http://support.microsoft.com/default.aspx?scid=kb;EN-US;217159

--
Alex Yakhnin .NET CF MVP
www.intelliprog.com | www.opennetcf.org

gee said:
Hi All,

Can I use FileSystemWatcher to monitor changes to the root directory of a
memory card? I'm trying to detect insert/remove of memory card. Below is
my snippet of code which does not seem to detect the event. Thanks in
advance for your insights.
Gee
(e-mail address removed)
==============================================

// default to false
IsFullFramework = false;

#region FULL_FRAMEWORK
IsFullFramework = System.Environment.OSVersion.Platform != PlatformID.WinCE;
#endregion


if (! IsFullFramework)
{
string[] CFNames = StorageCard.GetStorageCardNames();
// IPaq has internal RAM card, first storage card is the external CF card.
if (CFNames.Length < 2)
MessageBox.Show("Please insert RAM Card", "Notice");
else
{
DirectoryInfo[] CFDirectoryList = StorageCard.GetStorageCards();
FileWatcher = new FileSystemWatcher(CFDirectoryList[0].FullName);
FileWatcher.Changed += new FileSystemEventHandler(fsw_Changed);
FileWatcher.Created += new FileSystemEventHandler(fsw_Changed);
FileWatcher.Deleted += new FileSystemEventHandler(fsw_Changed);
FileWatcher.EnableRaisingEvents = true;
FileWatcher.IncludeSubdirectories = true;
}
}

private void fsw_Changed(object sender, FileSystemEventArgs e)
{
MessageBox.Show("Please insert RAM Card", "Notice");
}
 
Top