コード例 #1
0
ファイル: Program.cs プロジェクト: soywiz/phpcloudbox
        static void Main()
        {
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Form1());

            try
            {
                Task.Run(async () =>
                {
                    var LoginInfo = GetLoginInfo();

                    var Server = new PhpCloudBoxServer(LoginInfo.Url, LoginInfo.User, LoginInfo.Password);
                    var Synchronizer = new PhpCloudFolderSynchronizer(Server, @"c:\temp\cloudbox");
                    await Synchronizer.InitialDownloadAsync();
                    Console.WriteLine("Connected");

                    /*
                    Console.WriteLine(String.Join("\n", (await Server.GetFileListAsync()).Select(Item => Item.path)));
                    //await Server.DownloadFileAsync("test2.png");
                    //await Server.DownloadFileToAsync("test2.png", @"c:\temp\lol.png");
                    await Server.DeleteFileAsync("test.png");
                    await Server.AddAndUploadFileAsync("temp.bmp", @"c:\temp\temp.bmp");
                    */

                    Console.ReadKey();
                }).Wait();
            }
            catch (AggregateException AggregateException)
            {
                throw (AggregateException.InnerExceptions[0]);
            }
        }
コード例 #2
0
        static void Main()
        {
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Form1());

            try
            {
                Task.Run(async() =>
                {
                    var LoginInfo = GetLoginInfo();

                    var Server       = new PhpCloudBoxServer(LoginInfo.Url, LoginInfo.User, LoginInfo.Password);
                    var Synchronizer = new PhpCloudFolderSynchronizer(Server, @"c:\temp\cloudbox");
                    await Synchronizer.InitialDownloadAsync();
                    Console.WriteLine("Connected");

                    /*
                     * Console.WriteLine(String.Join("\n", (await Server.GetFileListAsync()).Select(Item => Item.path)));
                     * //await Server.DownloadFileAsync("test2.png");
                     * //await Server.DownloadFileToAsync("test2.png", @"c:\temp\lol.png");
                     * await Server.DeleteFileAsync("test.png");
                     * await Server.AddAndUploadFileAsync("temp.bmp", @"c:\temp\temp.bmp");
                     */

                    Console.ReadKey();
                }).Wait();
            }
            catch (AggregateException AggregateException)
            {
                throw (AggregateException.InnerExceptions[0]);
            }
        }
コード例 #3
0
		public PhpCloudFolderSynchronizer(PhpCloudBoxServer Server, string RootPath)
		{
			if (!Directory.Exists(RootPath)) Directory.CreateDirectory(RootPath);
			RootPath = new DirectoryInfo(RootPath).FullName;

			FileSystemWatcher = new FileSystemWatcher(RootPath);
			FileSystemWatcher.IncludeSubdirectories = true;
			FileSystemWatcher.InternalBufferSize = 1 * 1024 * 1024;
			Console.WriteLine(FileSystemWatcher.InternalBufferSize);
			FileSystemWatcher.Changed += FileSystemWatcher_Changed;
			FileSystemWatcher.Renamed += FileSystemWatcher_Renamed;
			FileSystemWatcher.Created += FileSystemWatcher_Created;
			FileSystemWatcher.Deleted += FileSystemWatcher_Deleted;
			FileSystemWatcher.EnableRaisingEvents = true;
			Changes = new Dictionary<string, DateTime>();

			this.Server = Server;
			this.RootPath = RootPath;

			UpdateThread = new Thread(UpdateThreadMain);
			UpdateThread.IsBackground = true;
			UpdateThread.Start();
		}