public async Task DeleteFile(string id)
        {
            var             client         = new SharePointClient(ServiceEndpointUri, GetAccessToken);
            IFileSystemItem fileSystemItem = await client.Files.GetByIdAsync(id);

            await fileSystemItem.DeleteAsync();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Deletes the selected item or folder from the ListBox.
        /// </summary>
        /// <returns>A Boolean value that indicates whether the file or folder was successfully deleted.</returns>
        internal async Task <bool?> DeleteFileOrFolderAsync(FileSystemItemViewModel _selectedFileObject)
        {
            bool?isSuccess = false;

            try
            {
                // Gets the FileSystemItem that is selected in the bound ListBox control.
                IFileSystemItem fileOrFolderToDelete = _selectedFileObject.FileSystemItem;

                // This results in a call to the service.
                await fileOrFolderToDelete.DeleteAsync();

                isSuccess = true;
            }
            catch (Microsoft.Data.OData.ODataErrorException)
            {
                isSuccess = null;
            }
            catch (NullReferenceException)
            {
                isSuccess = null;
            }

            return(isSuccess);
        }
        public async Task DeleteFile(string id)
        {
            var client = await EnsureClientCreated();

            IFileSystemItem fileSystemItem = await client.Files.GetByIdAsync(id);

            await fileSystemItem.DeleteAsync();
        }