FileSystemWatcher

  • Thread starter Thread starter jlea
  • Start date Start date
J

jlea

I'm trying to watch a file from my XP-Pro workstation to either a Win2000 or
a NT4 machine and everytime I try to set the path property to something such
as \\PDC1\cdrive\ I get a system.nullException error.

Anyone have any ideas? Does this work? It works just fine on my local
machine: "c:\abc\def\"

Thanks. Jon Lea
 
First question: Do you have permissions to that share?

Second: please post the full exception and stack trace along with a small
bit of code.

Thanks,
-mike
MVP
 
Thanks for the reply. I have permission to the share: I'm able to save a
file to that share from within Word. I'm using the following code:

void FileWatcher::SetFile(String* fullPathName)

{

FileInfo* fi = new FileInfo(fullPathName);

m_watcher->Path = fi->DirectoryName;

m_watcher->EnableRaisingEvents = true;

m_watcher->Filter = fi->Name;

}


and the exact exception is:

A "System.NullReferenceException" occured.
Object reference not set to an instance of an object.

and it occurs on this line:

m_watcher->Path = fi->DirectoryName;

and fi->DirectoryName returns \\Pdc1\cdrive\.

I was doing some searching on the net about the FileSystemWatcher and found
this link:

http://msdn.microsoft.com/library/d...otinguncpathnamesnotacceptedonnt4machines.asp

It sounds like FileSystemWatcher has a few problems with network file
watching.

Thanks again and let me know what you think. Jon.
 
Michael - I think I've solved my problem - its amazing what a day makes.
Apparently the FileInfo class drops the last "\" on network files and has it
for local drives. I added some code to make sure the last "\" is on the
directory name before asssigning it to the path property and things seem to
work now. So I can use my XP-Pro workstation to watch files on the NT4
server and also on another Win2000 workstation. I'm in the process of
testing it with a Win2000 workstation going to the NT4 server.

Thanks for the help. Jon.
 
I had also made some other changes in my attempt to fix things up when I
stumbled upon this so I don't know if this was the only/real culprit. A
colleague of mine here said he had seen the same behavior with FileInfo so
he wasn't surprised to hear it. Let me know what you find. Jon.
 
Back
Top