473,320 Members | 2,107 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

FileSystemWatcher

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
Jul 21 '05 #1
6 2943
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

"jlea" <jo*@leapsoft.com> wrote in message
news:Op**************@TK2MSFTNGP11.phx.gbl...
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

Jul 21 '05 #2
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/de...t4machines.asp

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

Thanks again and let me know what you think. Jon.
"Michael Giagnocavo [MVP]" <mg*******@Atrevido.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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

"jlea" <jo*@leapsoft.com> wrote in message
news:Op**************@TK2MSFTNGP11.phx.gbl...
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


Jul 21 '05 #3
What's the full stack trace? And to test, don't use NT4.
-mike
MVP

"jlea" <jo*@leapsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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/de...t4machines.asp
It sounds like FileSystemWatcher has a few problems with network file
watching.

Thanks again and let me know what you think. Jon.
"Michael Giagnocavo [MVP]" <mg*******@Atrevido.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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

"jlea" <jo*@leapsoft.com> wrote in message
news:Op**************@TK2MSFTNGP11.phx.gbl...
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



Jul 21 '05 #4
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.
"Michael Giagnocavo [MVP]" <mg*******@Atrevido.net> wrote in message
news:Oy****************@TK2MSFTNGP09.phx.gbl...
What's the full stack trace? And to test, don't use NT4.
-mike
MVP

"jlea" <jo*@leapsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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/de...t4machines.asp

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

Thanks again and let me know what you think. Jon.
"Michael Giagnocavo [MVP]" <mg*******@Atrevido.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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

"jlea" <jo*@leapsoft.com> wrote in message
news:Op**************@TK2MSFTNGP11.phx.gbl...
> 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
>
>



Jul 21 '05 #5
Great find, let me check into this.

Thanks,
-mike
MVP
"jlea" <jo*@leapsoft.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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.
"Michael Giagnocavo [MVP]" <mg*******@Atrevido.net> wrote in message
news:Oy****************@TK2MSFTNGP09.phx.gbl...
What's the full stack trace? And to test, don't use NT4.
-mike
MVP

"jlea" <jo*@leapsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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/de...t4machines.asp
It sounds like FileSystemWatcher has a few problems with network file
watching.

Thanks again and let me know what you think. Jon.
"Michael Giagnocavo [MVP]" <mg*******@Atrevido.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
> 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
>
> "jlea" <jo*@leapsoft.com> wrote in message
> news:Op**************@TK2MSFTNGP11.phx.gbl...
> > 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
> >
> >
>
>



Jul 21 '05 #6
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.

"Michael Giagnocavo [MVP]" <mg*******@Atrevido.net> wrote in message
news:OW**************@TK2MSFTNGP10.phx.gbl...
Great find, let me check into this.

Thanks,
-mike
MVP
"jlea" <jo*@leapsoft.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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.
"Michael Giagnocavo [MVP]" <mg*******@Atrevido.net> wrote in message
news:Oy****************@TK2MSFTNGP09.phx.gbl...
What's the full stack trace? And to test, don't use NT4.
-mike
MVP

"jlea" <jo*@leapsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> 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/de...t4machines.asp
>
> It sounds like FileSystemWatcher has a few problems with network file > watching.
>
> Thanks again and let me know what you think. Jon.
>
>
> "Michael Giagnocavo [MVP]" <mg*******@Atrevido.net> wrote in message
> news:%2****************@TK2MSFTNGP12.phx.gbl...
> > 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
> >
> > "jlea" <jo*@leapsoft.com> wrote in message
> > news:Op**************@TK2MSFTNGP11.phx.gbl...
> > > 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
> > >
> > >
> >
> >
>
>



Jul 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Josh Usovsky | last post by:
I'm setting up a watched folder using FileSystemWatcher. When I drop a small file into the watched folder, I can respond to a .Created event and process the file with other code. However, if I try...
1
by: Troy Murphy | last post by:
How do I prevent the FileSystemWatcher event to keep firing while the file is being created? When copying a file to the watched folder, the event fires a dozen or more times! Also, the...
7
by: Allen Anderson | last post by:
I'm trying to figure out a way to catch when a file has been written to a directory. I currently have it where I can catch when the file begins writing, but this isn't helpful as I need to know...
2
by: Jet Leung | last post by:
Hi all, I had made a program to watching files in my directory. I had used a instance of FileSystemWatcher to do my work.And I had add some events of the FileSystemWatcher , for example onChange,...
13
by: David | last post by:
I have been working on trying to write a directory watcher service. One of the requirments is that it be able to watch multiple directories, not sub directories of one parent directory, but just...
3
by: Stampede | last post by:
Hi, I want to use the FileSystemWatcher in a Windows Service. I read an article, where the author created the FileSystemWatcher object in a seperate thread and when the event is fired, he started...
20
by: J-T | last post by:
We are working on an asp.net application which is a 3-tier application.I was aksed to create a component which monitors a folder and gets the file and pass them to a class library in our business...
12
by: ljh | last post by:
Has anyone else noticed that the FileSystemWatcher raises the changed event twice when a file is changed? Do you have any idea why this is the case?
5
by: Goran Djuranovic | last post by:
Hi all, I have a file system watcher service that works fine on a local hard drive, but will not work across the network. I tried both: mapping the drive and "\\..." path both no luck. I don't...
5
by: =?Utf-8?B?Sm9obiBT?= | last post by:
I am trying to find out if there is a way to tell if there is already a filesystemwatcher (created by a webservice) monitoring a folder. I have a webservice that creates a filesystemwatcher,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.