Пример #1
0
        /// <summary>
        /// 创建XML的根节点
        /// </summary>
        private void CreateXMLElement()
        {
            //创建一个XML对象
            _xml = new XmlDocument();

            if (DirFile.IsExistFile(_filePath))
            {
                //加载XML文件
                _xml.Load(this._filePath);
            }

            //为XML的根节点赋值
            _element = _xml.DocumentElement;
        }
Пример #2
0
        /// <summary>
        /// 上传文件夹,就是把foldername文件夹内容(含文件夹)上传到FTPParh下面
        /// </summary>
        /// <param name="FTPParh">上传目录</param>
        /// <param name="foldername">本地目录</param>
        public void Uploadfolder(string FTPParh, string foldername)
        {
            DirectoryInfo folderInf = new DirectoryInfo(foldername);

            //判断FTP目标目录是否存在,若不存在则创建
            if (!FolderExist(folderInf.Name))
            {
                MakeDir(folderInf.Name);
            }
            //上传文件,判断本级文件夹下是否有文件夹,如果没有文件夹则返回"";
            string[] strFolderlist = DirFile.GetFolderNames(foldername);
            foreach (string strfoldername in strFolderlist)
            {
                //即存在文件夹
                if (strfoldername != "")
                {
                    //先上传本级目录下的文件
                    string[] strfilename = DirFile.GetFileNames(foldername);
                    for (int i = 0; i < strfilename.Length; i++)
                    {
                        Upload(FTPParh + folderInf.Name + "/", strfilename[i]);
                    }
                    //再递归下载本级目录下的文件夹
                    string s  = FTPParh + folderInf.Name + "/" + Path.GetFileName(strfoldername) + "/";
                    string ss = foldername + "\\" + Path.GetFileName(strfoldername);
                    Uploadfolder(FTPParh + folderInf.Name + "/" + Path.GetFileName(strfoldername) + "/", foldername + "\\" + Path.GetFileName(strfoldername));
                }
                else //不存在文件夹
                {
                    string[] strfilename = DirFile.GetFileNames(foldername);
                    for (int i = 0; i < strfilename.Length; i++)
                    {
                        Upload(FTPParh + folderInf.Name + "/", strfilename[i]);
                    }
                }
            }
        }