コード例 #1
0
        /// <summary>
        /// Performs a search of the default Documents folder.
        /// </summary>
        /// <returns>A collection of information that describes files and folders.</returns>
        internal async Task <List <model.FileObject> > GetMyFilesAsync()
        {
            var sharePointClient = await AuthenticationHelper.EnsureSharePointClientCreatedAsync("MyFiles");

            //IOrderedEnumerable<IFileSystemItem> files = null;

            List <model.FileObject> returnResults = new List <model.FileObject>();

            try
            {
                // Performs a search of the default Documents folder.
                // You could also specify other folders using the syntax: var filesResults = await _client.Files["folder_name"].ExecuteAsync();
                // This results in a call to the service.

                var filesResults = await sharePointClient.Files.ExecuteAsync();

                var files = filesResults.CurrentPage;

                foreach (IItem fileItem in files)
                {
                    // The item to add to the result set.
                    model.FileObject modelFile = new model.FileObject(fileItem);

                    returnResults.Add(modelFile);
                }
            }
            catch (ODataErrorException)
            {
                return(null);
            }
            catch (DataServiceQueryException)
            {
                return(null);
            }
            catch (MissingMethodException e)
            {
                Debug.Write(e.Message);
            }

            return(returnResults);
        }
        /// <summary>
        /// Performs a search of the default Documents folder. 
        /// </summary>
        /// <returns>A collection of information that describes files and folders.</returns>
        internal async Task<List<model.FileObject>> GetMyFilesAsync()
        {
            var sharePointClient = await AuthenticationHelper.EnsureSharePointClientCreatedAsync("MyFiles");
            //IOrderedEnumerable<IFileSystemItem> files = null;

            List<model.FileObject> returnResults = new List<model.FileObject>();

            try
            {
                // Performs a search of the default Documents folder.
                // You could also specify other folders using the syntax: var filesResults = await _client.Files["folder_name"].ExecuteAsync();
                // This results in a call to the service.

                var filesResults = await sharePointClient.Files.ExecuteAsync();

                var files = filesResults.CurrentPage;

                foreach (IItem fileItem in files)
                {
                    // The item to add to the result set.
                    model.FileObject modelFile = new model.FileObject(fileItem);

                    returnResults.Add(modelFile);
                }
            }
            catch (ODataErrorException)
            {
                return null;
            }
            catch (DataServiceQueryException)
            {
                return null;
            }
            catch (MissingMethodException e)
            {
                Debug.Write(e.Message);
            }

            return returnResults;
        }