Beispiel #1
0
        public NTShare CreateShare(string name, string description, WinAPI.NETAPI32.SHARE_TYPE type, string path)
        {
            var newShare = new WinAPI.NETAPI32.SHARE_INFO_502 {
                shi502_netname = name,
                shi502_remark  = description,
                shi502_type    = (uint)type,
                shi502_path    = path
            };
            uint paramErr;
            var  result = WinAPI.NETAPI32.NetShareAdd(this.Host, 502, ref newShare, out paramErr);

            if (result != 0)
            {
                throw new NetApiException(
                          result,
                          "Unable to create local share '{0}' on host '{1}'",
                          name,
                          Host
                          );
            }

            var share = new NTShare {
                Host = Host,
                Name = name
            };

            share.Refresh();
            return(share);
        }
Beispiel #2
0
 public bool CheckShare(string name, out WinAPI.NETAPI32.SHARE_TYPE shareType)
 {
     return(WinAPI.NETAPI32.NetShareCheck(this.NTCompatibleHostName, name, out shareType) == WinAPI.NETAPI32.NET_API_STATUS.NERR_Success);
 }