Monday, October 27, 2003 11:45 PM
bart
Creating shares with "backslash-sensitive strings" :(
I like the .NET Framework very much but there are still a lot of things which are not in there today (but which will be covered in Whidbey). Just think of setting permissions on files and folders. Fortunately there are some great libraries to help people with this ugly task, e.g. http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=e6098575-dda0-48b8-9abf-e0705af065d9. Today I had to fight with my C# code to get a share to work from within managed code. Not that easy but a pain to debug as well... For those interested this is the tricky Win32 call:
[DllImport("Netapi32.dll")]
private static extern int NetShareAdd(
[MarshalAs(UnmanagedType.LPWStr)]
string server, Int32 dwLevel, IntPtr buf, IntPtr parm_err);
It did the trick, however there were some issues to get it right... Never use a backslash at the end of a path, for example c:\temp\. This call doesn't like that at all and returns a great error with number 123 :) The Platform SDK was a must to sort it out while debugging. But finally, everything is working great. So, this problem did not affect my great love: .NET :)
Can't wait to get it to work in "Whidbey"...
Del.icio.us |
Digg It |
Technorati |
Blinklist |
Furl |
reddit |
DotNetKicks
Filed under: Personal, Microsoft