Example #1
0
        static void Main()
        {
            Console.WriteLine("{0,45}", "DropBox Client");
            line();

            DropboxClient client = new DropboxClient();

            DropboxApi api = client.connectDropbox("KsHXYcj-h_AAAAAAAAAAUr3Ebnrxv-Hrm8Vn7DYRZ5iEA3pw7xZG5jUs8E2UctRZ");


            var account = client.getInfoAccount(api);



            Console.WriteLine("{0,20}{1}", "Здравствуйте ", account.DisplayName);

            string command = "";

            help();

            while (true)
            {
                command = Console.ReadLine();

                switch (command)
                {
                case "VIEW_FILES": getFiles(api, client);
                    break;

                case "CREATE_FOLDER": createNewFolder(api, client);
                    break;

                case "DELETE": delete(api, client);
                    break;

                case "ADD_FILE": addFile(api, client);
                    break;

                case "DOWNLOAD_FILE": downloadFile(api, client);
                    break;

                default:
                    Console.WriteLine("Nothing");
                    break;
                }
            }
        }
Example #2
0
        public MainWindow()
        {
            InitializeComponent();
            selectedFolder  = "";
            lastFile        = "";
            selectedFolders = new List <string>();
            curs            = Properties.Settings.Default.cursor;
            client          = new DropboxClient();

            string folderUser = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);


            if (System.IO.Directory.Exists(folderUser + "\\" + "Синхронизируемая папка") == false)
            {
                System.IO.Directory.CreateDirectory(folderUser + "\\" + "Синхронизируемая папка");
            }

            if (Properties.Settings.Default.selectedFolders == null)
            {
                System.Collections.Specialized.StringCollection folders = new System.Collections.Specialized.StringCollection();
                folders.Add(folderUser + "\\" + "Синхронизируемая папка");
                Properties.Settings.Default.selectedFolders = folders;
                Properties.Settings.Default.Save();
            }

            Properties.Settings.Default.selecFolder = folderUser + "\\" + "Синхронизируемая папка";
            Properties.Settings.Default.Save();
            selectedFolder = folderUser + "\\" + "Синхронизируемая папка";
            if (String.IsNullOrEmpty(Properties.Settings.Default.AccessToken))
            {
                while (this.GetAccesToken() == false)
                {
                    Properties.Settings.Default.selecFolder = "";
                    Properties.Settings.Default.Save();
                }
            }

            api = client.connectDropbox(Properties.Settings.Default.AccessToken);
            getInfoUser(api);

            //moveFileInFolderAsync(api, "/Синхронизируемая папка");

            WindowState            = FormWindowState.Minimized;
            this.ShowInTaskbar     = false;
            notifyIconName.Visible = true;

            /*if (Properties.Settings.Default.cursorsFolders != null)
             * {
             *  for (int i = 0; i < Properties.Settings.Default.cursorsFolders.Count; i++)
             *  {
             *      folders.Add(Properties.Settings.Default.cursorsFolders[i]);
             *  }
             * }
             * else
             * {
             *  folders.Add(Properties.Settings.Default.cursor);
             * }*/

            Properties.Settings.Default.cursorsFolders = null;
            if (Properties.Settings.Default.cursorsFolders == null)
            {
                System.Collections.Specialized.StringCollection cF = new System.Collections.Specialized.StringCollection();
                for (int i = 0; i < Properties.Settings.Default.selectedFolders.Count; i++)
                {
                    cF.Add("");
                }
                Properties.Settings.Default.cursorsFolders = cF;
                Properties.Settings.Default.Save();
            }



            if (System.IO.Directory.Exists(Properties.Settings.Default.selecFolder))
            {
                if (Properties.Settings.Default.fl == null)
                {
                    Properties.Settings.Default.fl = "access";
                    Properties.Settings.Default.Save();
                    updateState(false);
                    getAllFiles(api, selectedFolder, "/" + selectedFolder.Split('\\').Last());
                    updateState(true);
                }
                else
                {
                    createNeedFolders(api, Properties.Settings.Default.selectedFolders);

                    for (int i = 0; i < Properties.Settings.Default.selectedFolders.Count; i++)
                    {
                        selectedFolders.Add(Properties.Settings.Default.selectedFolders[i]);
                        getStartedSynchronizationAsync(api, selectedFolders[i], i);
                        synchronizationAsync(api, selectedFolders[i], i);
                        createWatcher(selectedFolders[i]);
                    }
                }
            }
            else
            {
                System.IO.Directory.CreateDirectory(folderUser + "\\" + "Синхронизируемая папка");
                updateState(false);
                getAllFiles(api, selectedFolder, "/" + selectedFolder.Split('\\').Last());
                updateState(true);
            }
        }