9.3.11. Пример интеграции RobotNET Copy

sdk\c-sharp\copy\copy\Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;

using RobotNET.SDK;

namespace RoboCopy
{
    class Program
    {
        static void Main( string[] args )
        {
            Console.WriteLine( string.Format( "Program started!" ) );

            if( args.Count() > 4 )
            {
                string addr = args[0];
                string pass = args[1];
                string from = args[2];
                string to = args[3];
                bool local = args[4].ToLower() == "download" ? true : false;
                bool rewrite = false;
                bool move = false;
                string schedule = args.Count() > 5 ? args[5].ToLower() : null;
                bool execute = schedule != null && schedule == "execute" ? true : false;
                schedule = !execute ? schedule : null;

                try
                {
                    using( Copy copy = new Copy( addr, pass, uint.MaxValue ) )
                    {
                        if( schedule != null )
                            copy.Schedule( to, local );
                        else
                        {
                            copy.Progress += copy_Progress;

                            if( local )
                                copy.Download( from, to, rewrite, move, execute );
                            else
                                copy.Upload( from, to, rewrite, move, execute );
                        }
                    }
                }
                catch( Exception e )
                {
                    Console.WriteLine( e.ToString() );
                }
            }

            Console.WriteLine( string.Format( "Program finished!" ) );
        }

        static void copy_Progress( string file, long size, long pos, long status )
        {
            if( pos == 0 )
            {
                Console.WriteLine( file );
            }
            if( status == 0 )
            {
                Console.WriteLine( "ERROR!" );
            }
        }
    }
}