Ejemplo n.º 1
0
        private void PublishFileToFtp(Ini config, string sectionName, string file, string target)
        {
            FtpConnection con = new FtpConnection
            {
                EnableSSL = config.ReadBool(target, "ssl", true)
            };
            ConnectionString connectionString = config.ReadSetting(target, "Target");

            string user = config.ReadSetting(target, "Username");

            if (!string.IsNullOrEmpty(user))
            {
                connectionString.UserName = user;
            }

            string pass = config.ReadSetting(target, "Password");

            if (!string.IsNullOrEmpty(pass))
            {
                connectionString.Password = pass;
            }

            connectionString.Location = FileSystem.Combine('/', config.ReadSetting(target, "Path"), Path.GetFileName(file));
            SystemConsole.Write("<cyan>Upload<default>: {0} -> <cyan>{1}<default> ..", file, connectionString);
            con.Upload(connectionString, File.ReadAllBytes(file));
            SystemConsole.WriteLine(" <green>ok");

            bool move = config.ReadBool(sectionName, "move", false) | config.ReadBool(sectionName, "delete", false);

            SystemConsole.Write("<red>Delete<default>: {0} ..", file);
            File.Delete(file);
            SystemConsole.WriteLine(" <green>ok");
        }