Beispiel #1
0
        private static bool TryParseShareInfo(string[] values, string name, out ShareInfo share)
        {
            string path    = null;
            string remark  = null;
            var    maxUses = 0u;

            foreach (var c in values)
            {
                if (c.StartsWith("ShareName=", StringComparison.OrdinalIgnoreCase))
                {
                    name = c.Substring(10).Trim();
                }
                else if (c.StartsWith("Path=", StringComparison.OrdinalIgnoreCase))
                {
                    path = c.Substring(5).Trim();
                }
                else if (c.StartsWith("Remark=", StringComparison.OrdinalIgnoreCase))
                {
                    remark = c.Substring(7).Trim();
                }
                else if (c.StartsWith("MaxUses=", StringComparison.OrdinalIgnoreCase) && UInt32.TryParse(c.Substring(8), out var tmp))
                {
                    maxUses = tmp;
                }
            }

            if (String.IsNullOrEmpty(path))
            {
                share = null;
                return(false);
            }
            else
            {
                share = new ShareInfo(name, Procs.IncludeTrailingBackslash(path), remark, maxUses);
                return(true);
            }
        }         // func TryParseShareInfo