EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Creating a folder

Also by EldoS: CallbackDisk
Create virtual disks backed by memory or custom location, expose disk images as disks and more.
#8073
Posted: 11/06/2008 08:07:59
by Khayralla AL-Athari (Standard support level)
Joined: 09/23/2008
Posts: 75

Hi

I asked this question on another thread about disallowing a user from creating a file in the Virtual Drive in Windows Explorer in some cases. Just throw an error
Code
private void CbFsCreateFile(object sender, string FileName, uint DesiredAccess, uint FileAttributes, uint ShareMode, ref IntPtr FileHandleContext)
{..
throw new ECBFSError("Not allowed to create a file/folder.");
..
}


Throwing an error is work only for a file (file will not be shown in the Windows Explorer), but for a folder it is not work, i.e. the folder is created and shown to the user.
So, is it possible to cancel creating a folder in some cases?

Thanks

#8077
Posted: 11/06/2008 09:38:51
by Volodymyr Zinin (EldoS Corp.)

Hello.

Try to throw an error using the error code. For example throw the win32 error ERROR_ACCESS_DENIED (it has value 5). Like this:
throw new ECBFSError(ERROR_ACCESS_DENIED);
#8079
Posted: 11/06/2008 10:20:00
by Khayralla AL-Athari (Standard support level)
Joined: 09/23/2008
Posts: 75

throw new ECBFSError(5);//ERROR_ACCESS_DENIED);
Does not work
Folder was created.
#8080
Posted: 11/06/2008 10:30:30
by Volodymyr Zinin (EldoS Corp.)

I will check it up. Are you using the .NET2.0 version of the CallbackFS library?
#8081
Posted: 11/06/2008 10:48:27
by Khayralla AL-Athari (Standard support level)
Joined: 09/23/2008
Posts: 75

yes.

Version : 2.0.39.30509
Runtime Version: v2.0.50727

by the way.
this is how I throw the error

Code
        private void CbFsCreateFile(object sender, string FileName, uint DesiredAccess, uint FileAttributes, uint ShareMode, ref IntPtr FileHandleContext)
        {
            Try
            {
              ...
              if (vdir.Parent == null)
                    throw new ECBFSError(5);//ERROR_ACCESS_DENIED);
               ...
             }
             catch (Exception ex)
            {
              log.Write(ex.Message);
            }
          }


error message is "The operation completed successfully"
#8082
Posted: 11/06/2008 11:22:35
by Eugene Mayevski (EldoS Corp.)

I am not sure that I understand you. If you use catch statement, the exception won't reach CBFS API. You need to just throw the exception and CBFS API will catch it in the code which called the callback.


Sincerely yours
Eugene Mayevski
#8083
Posted: 11/06/2008 11:49:18
by Khayralla AL-Athari (Standard support level)
Joined: 09/23/2008
Posts: 75

Throwing just the error will create another error.
"ECBFError was unhandled by user code"
and the Message is "The operation completed successfully"



#8084
Posted: 11/06/2008 12:07:10
by Eugene Mayevski (EldoS Corp.)

I don't understand you. Your code should look like

CbFsCreateFile(...)
{
...
if (should_not_create)
throw ECBFSError(ERROR_ACCESS_DENIED);
}

and that's all. No catch statement must be present in the code.


Sincerely yours
Eugene Mayevski
#8086
Posted: 11/06/2008 12:18:33
by Khayralla AL-Athari (Standard support level)
Joined: 09/23/2008
Posts: 75

Did you test it.
throw ECBFSError(ERROR_ACCESS_DENIED);
or
throw new ECBFSError(ERROR_ACCESS_DENIED);

#8087
Posted: 11/06/2008 12:29:19
by Eugene Mayevski (EldoS Corp.)

no, I didn't. But the point was not in the right syntax, but in the fact that you should not catch this exception in your code.


Sincerely yours
Eugene Mayevski
Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages

Reply

Statistics

Topic viewed 7537 times

Number of guests: 2, 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!