EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Problem using NotifyDirectoryChange

Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.
#23348
Posted: 02/04/2013 08:34:33
by Davide Baccaglini (Standard support level)
Joined: 11/19/2012
Posts: 48

Hello, I've a problem using NotifyDirectoryChange method.

In my application I create a virtual storage for remote content and I create a versioning system that can be used by context menu click.
In this case I create file '\MyFile.txt' (size 20 bytes) and after that I create a new versio of '\MyFile.txt' (size 50 bytes).

After I download the older version (20 bytes), in OnEnumerateDirectory my server return a Virtual File with the correct size (20 bytes) and I passed it ad CBFS. But when I try to open this file, the filesystem try to read a file of 50 bytes, not 20 bytes.

I read in this forum that if files are modified outside virtual storage I have to call NotifyDirectoryChange method for the file that was modified externally. Is it right?

In my code I try to do this, after download the older version and before to open the file, using :

bool result = callback.NotifyDirectoryChange('\MyFile.txt', CbFsNotifyFileAction.fanModified, true)

and result is always true, but when I open the file the filesystem try always to open a file of 50 bytes, that is the newer size (incorrect).

After this test I try to call NotifyDirectoryChange in another project (as suggested in the forum) but also in this case NotifyDirectoryChange not works. In this second test I used this code :

CallbackFileSystem callback = new CallbackFileSystem();
CallbackFileSystem.Initialize(ProjectResource.CBFS_INSTALL_GUID_V4);
CallbackFileSystem.SetRegistrationKey(ProjectResource.CBFS_LICENSE_KEY_V4);
bool result = callback.NotifyDirectoryChange('\MyFile.txt', CbFsNotifyFileAction.fanModified, true);
Console.WriteLine(" NOTIFY_DIRECTORY_CHANGE " + fileName + " RESULT" + result);

but in this case CBFS return me this error : storage is not active.

Can anyone help me?

Thanks in advance,
Davide
#23351
Posted: 02/04/2013 10:33:50
by Volodymyr Zinin (EldoS Corp.)

Hello Davide,

Quote
Davide Baccaglini wrote:
I read in this forum that if files are modified outside virtual storage I have to call NotifyDirectoryChange method for the file that was modified externally. Is it right?

You are right.

Quote
Davide Baccaglini wrote:
bool result = callback.NotifyDirectoryChange('\MyFile.txt', CbFsNotifyFileAction.fanModified, true)

Shouldn't it be two backslashes in the file name?
#23356
Posted: 02/06/2013 10:05:44
by Davide Baccaglini (Standard support level)
Joined: 11/19/2012
Posts: 48

Vladimir, I used NotifyDirectoryChange in wrong way when I pass path file to the method.

Thank you,
Davide

Reply

Statistics

Topic viewed 767 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!