mardi 29 avril 2014

c# - CeCreateDirectory via RAPI échoue, ne sais pas pourquoi - Stack Overflow


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.




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.




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.



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.



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.



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.


0 commentaires:

Enregistrer un commentaire