EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Force file/folder name

Posted: 06/02/2011 09:25:13
by Brent Y (Basic support level)
Joined: 06/02/2011
Posts: 4

I am evaluating CBFS to see if it will work for an upcoming project.

What I would like to do is force the names for new files and folders to something specified in code.

So if a user creates a new folder in Windows Explorer, I dont want the name to be 'New Folder', I would like it something else that the user cannot change.

So using the Mapper sample (C#), I put some code in the CbFsCreateFile() method to change the value of FileName. This works ok, but the folder in explorer still shows 'New Folder' until I hit refresh.

Is there a way to tell explorer the new name? Or is there some other way I should be going about this?

Thanks much,
Posted: 06/02/2011 09:37:34
by Eugene Mayevski (Team)

Use NotifyDirectoryChanges method to tell the OS to re-read the directory. There were several discussions about this method here (please use Search). Note, that the method may not be called right from callback - you need to postpone the notification by queueing the task in some way (send a windows message to main thread or use a separate worker thread for such tasks).

Sincerely yours
Eugene Mayevski
Posted: 06/02/2011 10:17:01
by Brent Y (Basic support level)
Joined: 06/02/2011
Posts: 4

Sorry, I tried searching but could not find what I was looking for. The NotifyDirectoryChanges led me to the right place though. Thanks, works great.
Posted: 06/06/2011 12:01:33
by Brent Y (Basic support level)
Joined: 06/02/2011
Posts: 4

I was able to figure out the folder side of this, but not the file part. If anyone could give me some direction...

How can I dictate the filename when someone does a Save As from an application to a virtual drive? The NotifyDirectoryChanges I think will only work when creating a folder. I don't know of any way to change the filename and then have the application point to the new name and not the original one the user entered in the save as dialog.

There is probably a different approach, but I haven't found it yet.

Posted: 06/06/2011 12:27:37
by Eugene Mayevski (Team)

Most likely the file name is cached while the file is opened. Not sure if you can change this.

Sincerely yours
Eugene Mayevski



Topic viewed 1499 times

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


Back to top

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

Got it!