示例#1
0
        private string LoadFiles(OneDriveContent oneDriveContent)
        {
            listViewFiles.Items.Clear();
            if (_roots.Count > 0)
            {
                var item = new ListViewItem("..");
                var sc   = new OneDriveContent
                {
                    Type     = "folder",
                    ParentId = _roots.Peek()
                };
                sc.Id           = sc.ParentId;
                item.Tag        = sc;
                item.ImageIndex = 1;
                listViewFiles.Items.Add(item);
            }
            string path = string.Empty;

            comboBoxFileName.Items.Clear();
            foreach (OneDriveContent f in _api.GetFiles(oneDriveContent, out _pathId))
            {
                path = f.Path;
                if (f.IsFile || f.IsFolder)
                {
                    ListViewItem item = new ListViewItem(f.Name);
                    item.SubItems.Add(f.UpdatedTime.ToShortDateString() + " " + f.UpdatedTime.ToShortTimeString());
                    item.SubItems.Add(FormatBytesToDisplayFileSize(f.Size));
                    item.Tag = f;
                    if (f.IsFile)
                    {
                        item.ImageIndex = 0;
                        comboBoxFileName.Items.Add(f.Name);
                    }
                    else
                    {
                        item.ImageIndex = 1;
                    }
                    listViewFiles.Items.Add(item);
                }
            }
            if (listViewFiles.Items.Count > 0)
            {
                listViewFiles.Items[0].Selected = true;
            }
            return(path);
        }