CeCreateDirectory via RAPI fails, not sure why

254 views Asked by At

I have the following code:

  [DllImport("rapi.dll", CharSet = CharSet.Unicode)]
        public static extern bool CeCreateDirectory(string lpPathName, IntPtr lpSecurityAttributes);

and in a function I've attempted, amongst other things, the following:

CeCreateDirectory( "\\fail\\", ptr )
CeCreateDirectory( "C:\\fail\\", ptr )
CeCreateDirectory( "\\fail", ptr )
CeCreateDirectory( "C:\\fail", ptr )

Every time the function returns false, I just want to create a directory on the device but not sure how.

2

There are 2 answers

0
ctacke On

Did you first call CeRapiInit (or CeRapiInitEx)? And why reinvent the wheel? All of this RAPI stuff is already wrapped and open-sourced in the OpenNETCF Desktop Communication library.

3
AudioBubble On

Not sure about Windows CE, but Windows Mobile doesn't support the "C:\" part.

CeCreateDirectory( "C:\\fail\\", ptr )

Have you tried using the System.IO.Directory class?

Directory.CreateDirectory("\\fail");

May also need to leave the last "\" character off, too.