小编Azu*_*ith的帖子

使用Microsoft图形C#ASP.NET将新文件上传到OneDrive

尝试将文件上传到尚不存在的onedrive。我设法得到它来更新现有文件。但是似乎无法弄清楚如何创建一个全新的文件。我已经使用Microsoft.Graph库完成了此操作。

以下是用于更新现有文件的代码:

public async Task<ActionResult> OneDriveUpload()
    {
        string token = await GetAccessToken();
        if (string.IsNullOrEmpty(token))
        {
            // If there's no token in the session, redirect to Home
            return Redirect("/");
        }

        GraphServiceClient client = new GraphServiceClient(
            new DelegateAuthenticationProvider(
                (requestMessage) =>
                {
                    requestMessage.Headers.Authorization =
                        new AuthenticationHeaderValue("Bearer", token);

                    return Task.FromResult(0);
                }));


        try
        {
            string path = @"C:/Users/user/Desktop/testUpload.xlsx";
            byte[] data = System.IO.File.ReadAllBytes(path);
            Stream stream = new MemoryStream(data);
            // Line that updates the existing file             
            await client.Me.Drive.Items["55BBAC51A4E4017D!104"].Content.Request().PutAsync<DriveItem>(stream);

            return View("Index");
        }
        catch (ServiceException ex)
        { …
Run Code Online (Sandbox Code Playgroud)

c# onedrive microsoft-graph

5
推荐指数
1
解决办法
2781
查看次数

SQL - 从下一个最低ID中获取值

我在SQL Server 2014 Management Studio中工作.

不确定如何解释这个,但最好是我只是用一个例子来解释.

所以我想出了如何获得下一个最低ID,这很简单.但是一旦我得到那一行,我需要从中获取值并将其应用到下一个最高值.

如果我有4行

ID      value
-------------
10        50
30       200
20        75
25       100
Run Code Online (Sandbox Code Playgroud)

我想获取每一行的值并应用具有下一个最高ID的行.所以看起来应该是这样的.

ID      value
-------------
10      null or 0
30      100
20       50
25       75
Run Code Online (Sandbox Code Playgroud)

由于10 ID之前没有行,该行的值应为null或0,无关紧要.其他人应该遵循从具有下一个最低ID的行中获取值的模式.

sql sql-server sql-server-2014

3
推荐指数
1
解决办法
97
查看次数

我如何比较两个锯齿状数组中的数组 C#

好的,我有 2 个锯齿状数组,我想循环遍历它们并将每个数组与另一个锯齿状数组中的每个数组进行比较。所以在这个例子中我想当 access[1] == Visual[0] 时返回 true。

但似乎我无法显式比较锯齿状数组中的数组。我如何引用整个数组,而不仅仅是这些数组中的元素?我的意思是,如果我写,access[0][0]我就会得到"10"。但我不能写access[0]得到"10","16"

string[][] access = new string[][] {
                    new string[] {"10","16"},
                    new string[] {"100","20"},
                    new string[] {"1010","2"},
                    new string[] {"1011","1"}
                };

string[][] visual = new string[][] {
                new string[] {"100","20"},
                new string[] {"101","36"},
                new string[] {"101","37"},
                new string[] {"101","38"}
            };
Run Code Online (Sandbox Code Playgroud)

c# arrays comparison compare jagged-arrays

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