Exemple #1
0
        public void OpenDirectory(string path)
        {
            lvDropboxFiles.Items.Clear();

            DropboxContentInfo contentInfo = null;

            TaskEx.Run(() =>
            {
                contentInfo = dropbox.GetMetadata(path, true);
            },
                       () =>
            {
                if (contentInfo != null)
                {
                    lvDropboxFiles.Tag = contentInfo;

                    ListViewItem lvi = GetParentFolder(contentInfo.Path);

                    if (lvi != null)
                    {
                        lvDropboxFiles.Items.Add(lvi);
                    }

                    foreach (DropboxContentInfo content in contentInfo.Contents.OrderBy(x => !x.Is_dir))
                    {
                        string filename = Path.GetFileName(content.Path);
                        lvi             = new ListViewItem(filename);
                        lvi.SubItems.Add(content.Is_dir ? "" : content.Size);
                        DateTime modified;
                        if (DateTime.TryParse(content.Modified, out modified))
                        {
                            lvi.SubItems.Add(modified.ToString());
                        }
                        lvi.ImageKey = ilm.AddImage(content.Icon);
                        lvi.Tag      = content;
                        lvDropboxFiles.Items.Add(lvi);
                    }

                    CurrentFolderPath = contentInfo.Path.Trim('/');
                    Text = "Dropbox - " + CurrentFolderPath;
                }
                else
                {
                    MessageBox.Show(Resources.DropboxFilesForm_OpenDirectory_Path_not_exist_ + " " + path, Resources.UploadersConfigForm_Error,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            });
        }