Example #1
0
        public string FtpMethod(string doType, string v1, string v2, string v3)
        {
            try
            {
                FtpSupport.FtpConnection conn = new FtpSupport.FtpConnection("192.168.1.138", "administrator", "jiaozi");
                switch (doType)
                {
                case "ShareFrm":     /*共享模板*/
                    MapData md   = new MapData();
                    DataSet ds   = md.GenerHisDataSet();
                    string  file = BP.SystemConfig.PathOfTemp + v1 + "_" + v2 + "_" + DateTime.Now.ToString("MM-dd hh-mm") + ".xml";
                    ds.WriteXml(file);
                    conn.SetCurrentDirectory("/");
                    conn.SetCurrentDirectory("/Upload.Form/");
                    conn.SetCurrentDirectory(v3);
                    conn.PutFile(file, md.Name + ".xml");
                    conn.Close();
                    return(null);

                case "GetDirs":
                    //   return "@01.日常办公@02.人力资源@03.其它类";
                    conn.SetCurrentDirectory(v1);
                    FtpSupport.Win32FindData[] dirs = conn.FindFiles();
                    conn.Close();
                    string dirsStr = "";
                    foreach (FtpSupport.Win32FindData dir in dirs)
                    {
                        dirsStr += "@" + dir.FileName;
                    }
                    return(dirsStr);

                case "GetFls":
                    conn.SetCurrentDirectory(v1);
                    FtpSupport.Win32FindData[] fls = conn.FindFiles();
                    conn.Close();
                    string myfls = "";
                    foreach (FtpSupport.Win32FindData fl in fls)
                    {
                        myfls += "@" + fl.FileName;
                    }
                    return(myfls);

                case "LoadTempleteFile":
                    string fileFtpPath = v1;
                    conn.SetCurrentDirectory("/Form.表单模版/");
                    conn.SetCurrentDirectory(v3);

                    /*下载文件到指定的目录: */
                    string tempFile = BP.SystemConfig.PathOfTemp + "\\" + v2 + ".xml";
                    conn.GetFile(v1, tempFile, false, FileAttributes.Archive, FtpSupport.FtpTransferType.Ascii);
                    return(this.LoadFrmTempleteFile(tempFile, v2, true, true));

                default:
                    return(null);
                }
            }
            catch (Exception ex)
            {
                return("Error:" + ex.Message);
            }
        }