コード例 #1
0
        // downloads and handles the global config file from the ftp server
        private void Init()
        {
            connected = true;

            // set remote path (e.g. "ftp://www.example.com/myFolder")
            remotePath = new Uri(protocol + Settings.Path);

            // set credentials (username, password, passive mode)
            fileTransfer.Client.Credentials = new NetworkCredential(Settings.User, Settings.Password);
            fileTransfer.Client.UsePassive  = Settings.Passive;

            // download global config async
            TransferFile file = new TransferFile(globalConfig);

            fileTransfer.DownloadFileAsync(file, false, remotePath, localPath,
                                           // callback of the download
                                           delegate(FileTransferResult result)
            {
                if (exit)
                {
                    FireExit();
                }
                else
                {
                    // versions object handels global config file if download has been successful
                    if (result == FileTransferResult.Success)
                    {
                        versions.Load(localPath + globalConfig);
                    }

                    // fire some events
                    ResetInterface();
                }
            });
        }