EldoS | Feel safer!

Software components for data protection, secure storage and transfer

NotifyDirectoryChange Questions

Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages
#10941
Posted: 09/02/2009 23:22:40
by Gavin McKay (Standard support level)
Joined: 09/01/2009
Posts: 48

Hi all,

I have some questions about the functionality of the NotifyDirectoryChange method. I'm using .NET 32-bit addition. I've read pretty much all the forum topics here on NotifyDirectoryChange, and I am pretty sure I understand when you want to use it - when anything external to your CbFs application modifies a file and/or folder that is being monitored by your application.

I am using Windows Explorer to test my CbFs implementation on a directory I provide "\test\". I have a test application that creates a "\Test\notify.txt" external to CbFs and adds it to my external file storage database. I then force a NotifyDirectoryChange event via my test app like so:

bool notifed = mCbFs.NotifyDirectoryChange("\Test\notify.txt", CbFsNotifyFileAction.fanAdded);

and "notified" returns True. This occurs outside a CbFs event, which I believe, on reading the forum topics, is the correct method. I would then expect Windows Explorer to refresh itself, but it doesn't. I also expect an OnEnumerateDirectory event to occur, but that doesn't happen either. Am I missing something? I've also tried NotifyDirectoryChange using "\Test\" and "\Test" but no luck there either.

Regards,

Gavin.
#10943
Posted: 09/03/2009 04:29:09
by Volodymyr Zinin (EldoS Corp.)

Hi Gavin,

Your work with NotifyDirectoryChange is absolutely correct. But something is wrong in our code. Please wait until we fix it.
#10944
Posted: 09/03/2009 06:11:57
by Volodymyr Zinin (EldoS Corp.)

Seems I've found where the problem is. The path you pass to NotifyDirectoryChange must be case sensitive.
So if explorer shows a directory with the name "test" on a CallbackFS virtual drive and a file "notify.txt" has been added outside CallbackFS then call
cbfs.NotifyDirectoryChange("\\test\\notify.txt", CbFsNotifyFileAction.fanAdded);
Please check whether it works for you.
Thanks.
#10950
Posted: 09/03/2009 23:48:37
by Gavin McKay (Standard support level)
Joined: 09/01/2009
Posts: 48

Hi Vladimir,

Looks like it is a combination of two things - the path needs a single double-backslash instead of two i.e. "\Test\notify.txt" instead of "\\Test\notify.txt", and also I can confirm that the NotifyDirectoryChange function is case-sensitive. I tested correct and incorrect case, and it only responds if the case matches.

I remember reading somewhere on the forums about the double-backslash which put me on to that, and your info about case-sensitivity fixed part two. As soon as I fixed that I received the OnEnumerateDirectory straight away. I don't really think the case-sensitivity is that much of an issue - at least it isn't for me :)

An additional question about NotifyDirectoryChange: if I have a folder with (say) 10 files, and externally 10 files are added all at once, should I call a NotifyDirectoryChange for each file with fanAdded, or just a single call to the containing folder and fanModified?

Gavin.
#10954
Posted: 09/04/2009 00:34:08
by Eugene Mayevski (EldoS Corp.)

There were no double backslashes in the original messages. Two double-slashes in Vladimir's post is C++ / C# notation for escaping certain symbols.

Quote
Gavin McKay wrote:
An additional question about NotifyDirectoryChange: if I have a folder with (say) 10 files, and externally 10 files are added all at once, should I call a NotifyDirectoryChange for each file with fanAdded, or just a single call to the containing folder and fanModified?


As I know it, you can notify about folder change as well.


Sincerely yours
Eugene Mayevski
#10955
Posted: 09/04/2009 01:25:24
by Volodymyr Zinin (EldoS Corp.)

Quote
Gavin McKay wrote:
An additional question about NotifyDirectoryChange: if I have a folder with (say) 10 files, and externally 10 files are added all at once, should I call a NotifyDirectoryChange for each file with fanAdded, or just a single call to the containing folder and fanModified?

Yes, you should notify about all external changes by means of NotifyDirectoryChange. Of course, you can at first add all the files and only then call NotifyDirectoryChange for each of them.

Quote
Eugene Mayevski wrote:
As I know it, you can notify about folder change as well.

In the case when only files are added to a folder, the folder itself isn't modified and it's necessary to notify only about the added files. But if for example some directory has been changed (renamed, etc) than NotifyDirectoryChange should be called for it.
Also by EldoS: CallbackProcess
A component to control process creation and termination in Windows and .NET applications.

Reply

Statistics

Topic viewed 2738 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!