Esempio n. 1
0
        /// <summary>
        /// ¼Ç¼ÅäÖÃ
        /// </summary>
        public void LoadConfig()
        {
            string path = CommonMethods.GetBaseRoot("config.xml");

            if (!File.Exists(path))
            {
                return;
            }
            try
            {
                XmlDocument xml = new XmlDocument();
                xml.Load(path);
                XmlNode      root = xml.GetElementsByTagName("root")[0];
                XmlAttribute attr = root.Attributes["ip"];
                if (attr != null)
                {
                    _bindIP = attr.InnerText;
                }
                attr = root.Attributes["port"];
                if (attr != null)
                {
                    _bindPort = Convert.ToInt32(attr.InnerText);
                }
                attr = root.Attributes["pwd"];
                if (attr != null)
                {
                    _password = attr.InnerText;
                }
                XmlNodeList items = root.ChildNodes;
                foreach (XmlNode item in items)
                {
                    ShareInfo info = new ShareInfo();
                    attr = item.Attributes["name"];
                    if (attr != null)
                    {
                        info.Name = attr.InnerText;
                    }
                    attr = item.Attributes["path"];
                    if (attr != null)
                    {
                        info.Path = attr.InnerText;
                    }

                    _shareInfos.Add(info);
                }
            }
            catch { }
        }
Esempio n. 2
0
        /// <summary>
        /// 获取文件夹
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        private string GetDirectory(string url, out string fileName, out bool isRoot)
        {
            string[]      parts = url.Split('/');
            StringBuilder dir   = new StringBuilder();

            fileName = "";
            for (int i = 0; i < parts.Length; i++)
            {
                string part = parts[i];
                string cur  = HttpUtility.UrlDecode(part.Trim());
                if (string.IsNullOrEmpty(cur))
                {
                    continue;
                }
                if (dir.Length == 0)
                {
                    ShareInfo info = _config.ShareInfos.FindItem(cur);
                    if (info != null)
                    {
                        dir.Append(info.Path.TrimEnd('\\', ' '));
                        dir.Append("\\");
                    }
                }
                else if (i >= parts.Length - 1)
                {
                    fileName = cur;
                }
                else
                {
                    dir.Append(cur);
                    dir.Append("\\");
                }
            }
            isRoot = parts.Length <= 1;
            return(dir.ToString());
        }