Example #1
0
        public async static Task <List <OneDriveFileInfo> > GetFilesInfoAsync(string folderId, string fileExtension)
        {
            List <OneDriveFileInfo> files = new List <OneDriveFileInfo>();

            try
            {
                LiveOperationResult operationResult = await _client.GetAsync(folderId + "/files");

                dynamic result = operationResult.Result;
                foreach (dynamic file in result.data)
                {
                    if (file.type == "file" && ((string)file.name).EndsWith(fileExtension))
                    {
                        DateTime created = DateTime.MinValue;
                        DateTime.TryParse(file.created_time, out created);

                        OneDriveFileInfo fileInfo = new OneDriveFileInfo
                        {
                            Id       = file.id,
                            Name     = file.name,
                            FolderId = file.parent_id,
                            Created  = created
                        };
                        files.Add(fileInfo);
                    }
                }
            }
            catch (Exception) { }
            return(files);
        }
        public void OneDriveListFolders(OneDriveFileInfo fileEntry, TreeNode tnParent)
        {
            Application.DoEvents();
            OneDrive         oneDrive         = new OneDrive(Config.OneDriveV2OAuth2Info);
            OneDriveFileList oneDrivePathInfo = oneDrive.GetPathInfo(fileEntry.id);

            tnParent.Nodes.Clear();
            foreach (OneDriveFileInfo folder in oneDrivePathInfo.value)
            {
                OneDriveAddFolder(folder, tnParent);
            }
        }
Example #3
0
        static void OneDriveStorageRemoveAction(string key, object value, CacheItemRemovedReason reason)
        {
            OneDriveFileInfo oneDriveFile = value as OneDriveFileInfo;

            if (oneDriveFile != null)
            {
                OneDriveFileSystemProvider provider = new OneDriveFileSystemProvider("UploadedFiles");
                provider.AccountName   = oneDriveFile.AccountName;
                provider.TokenEndpoint = oneDriveFile.TokenEndpoint;
                provider.RedirectUri   = oneDriveFile.RedirectUri;
                FileManagerFile file = new FileManagerFile(provider, oneDriveFile.FileKeyName);
                provider.DeleteFile(file);
            }
        }
        private void OneDriveAddFolder(OneDriveFileInfo folder, TreeNode tnParent)
        {
            TreeNode tn = new TreeNode(folder.name);

            tn.Tag = folder;
            tn.Nodes.Add(new TreeNode(Resources.UploadersConfigForm_OneDriveAddFolder_Querying_folders___));

            if (tnParent != null)
            {
                tnParent.Nodes.Add(tn);
            }
            else
            {
                tvOneDrive.Nodes.Add(tn);
            }
        }
Example #5
0
        public static void RemoveFileFromOneDriveWithDelay(string fileKeyName, string accountName, string tokenEndpoint, string redirectUri, int delay)
        {
            OneDriveFileInfo oneDriveFile = new OneDriveFileInfo(fileKeyName, accountName, tokenEndpoint, redirectUri);

            RemoveFileWithDelayInternal(fileKeyName, oneDriveFile, delay, OneDriveStorageRemoveAction);
        }