小编kem*_*yyy的帖子

如何使用c#在Sharepoint库子文件夹中上传文件?

我需要在sharepoint库中使用c#console app上传文件.我设法只将它上传到父库.但要求是将其上传到其子文件夹.
所以这是文件夹结构:

根文件

- 子文件夹1 ---子文件夹2
----子文件夹3

我需要将它上传到子文件夹3.现在,我只能上传根文件夹.当我尝试在GetByTitle方法中输入子文件夹3时会抛出错误,但是当它是根文件夹时,它会成功上载.

这是我的代码.

using (ClientContext clientContext = new ClientContext(siteURL))
{
    clientContext.Credentials = new System.Net.NetworkCredential(@"username", "password", "domain");

    var web = clientContext.Web;

    // Create the new file  
    var newFile = new FileCreationInformation();
    newFile.Content = System.IO.File.ReadAllBytes(@"C:\filepath\test.xlsx");
    newFile.Overwrite = true;
    newFile.Url = "Test Upload.xlsx";

    List list = web.Lists.GetByTitle("Service Oriented Architecture (SOA)");
    clientContext.Load(list);
    clientContext.ExecuteQuery();
    clientContext.Load(list.RootFolder);
    clientContext.Load(list.RootFolder.Folders);

    clientContext.ExecuteQuery();

    foreach (Folder SubFolder in list.RootFolder.Folders)
    {
        if (SubFolder.Name.Equals("07 - SOA Environment"))
        {
            //What's next?
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

.net c# sharepoint file-upload sharepoint-2010

7
推荐指数
1
解决办法
2万
查看次数

使用Progress Bar WPF进行异步Google文件上传

我使用服务帐户上传到Google云端存储.我需要能够在WPF UI中显示上传的进度.现在,每当我尝试更新ProgressBar.Value时,它都不起作用,但是当我在控制台中编写bytesSent时,我可以看到进度.

    public async Task<bool> UploadToGoogleCloudStorage(string bucketName, string token, string filePath, string contentType)
    {
        var newObject = new Google.Apis.Storage.v1.Data.Object()
        {
            Bucket = bucketName,
            Name = System.IO.Path.GetFileNameWithoutExtension(filePath)
        };
        var service = new Google.Apis.Storage.v1.StorageService();

        try
        {
            using (var fileStream = new FileStream(filePath, FileMode.Open))
            {

                var uploadRequest = new ObjectsResource.InsertMediaUpload(service, newObject, bucketName, fileStream, contentType);
                uploadRequest.OauthToken = token;
                ProgressBar.Maximum = fileStream.Length;
                uploadRequest.ProgressChanged += UploadProgress;
                uploadRequest.ChunkSize = (256 * 1024);
                await uploadRequest.UploadAsync().ConfigureAwait(false);
                service.Dispose();

            }

        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            throw ex;
        }
        return true; …
Run Code Online (Sandbox Code Playgroud)

.net c# wpf google-cloud-storage progress-bar

5
推荐指数
0
解决办法
599
查看次数