Exemplo n.º 1
0
        /// <summary>
        /// Writes the appropriate PersonsStore properties to the config file.
        /// </summary>
        public static void WriteConfig()
        {
            // xml document creation.
            var xmlDoc = new XmlDocument();

            // root node creation.
            XmlNode rootNode = xmlDoc.CreateElement("config");

            xmlDoc.AppendChild(rootNode);

            XmlNode rootPathNode = xmlDoc.CreateElement("rootPath");

            rootPathNode.InnerText = RootPath.ToString();
            rootNode.AppendChild(rootPathNode);

            // XmlWritter settings -> how the xml will be created in file.
            XmlWriterSettings settings = new XmlWriterSettings
            {
                Encoding           = Encoding.UTF8,
                ConformanceLevel   = ConformanceLevel.Document,
                OmitXmlDeclaration = false,
                CloseOutput        = true,
                Indent             = true,
                IndentChars        = "  ",
                NewLineHandling    = NewLineHandling.Replace
            };

            // Save the xml to the config file.
            using (FileStream configStream = File.Open(ConfigFilePath, FileMode.Create))
                using (XmlWriter writer = XmlWriter.Create(configStream, settings))
                {
                    xmlDoc.WriteContentTo(writer);
                }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Connect to the FTP server using the supplied Url, UserName and Password.
        /// Then change directory to the supplied Site and Home root paths.
        /// </summary>
        /// <returns></returns>
        public override FtpResponse Connect()
        {
            FtpResponse resp = base.Connect();

            RootPath absRoot = CompleteHomePath;

            if (absRoot != null)
            {
                ChangeDirectory(absRoot.ToString());
            }

            return(resp);
        }