how can use Yandex Disk c# Api

1k Views Asked by At

We want to use yandex disk api. Users can upload and delete files using the yandex disk.

I think getting a token from a login page. I tried a lot of sdk but I couldn't find the sample code working properly.

Could you help? i use https://github.com/yandex-disk/yandex-disk-sdk-csharp sdk

but sdk is WPF i use winform

this.sdkClient.AuthorizeAsync(new WebBrowserBrowser(browser), CLIENT_ID, RETURN_URL, this.CompleteCallback);
…
private void CompleteCallback(object sender, GenericSdkEventArgs<string> e)
{
    if (this.AuthCompleted != null)
    {
        this.AuthCompleted(this, new GenericSdkEventArgs<string>(e.Result));
    }

    this.Close();
}

public event EventHandler<GenericSdkEventArgs<string>> AuthCompleted;
1

There are 1 best solutions below

0
On BEST ANSWER

Implementing the solution to your problem at the bottom of the page on GitHub: https://github.com/raidenyn/yandexdisk.client

// PM> Install-Package YandexDisk.Client

using YandexDisk.Client.Http;
using YandexDisk.Client.Clients;

namespace Yandex_Disk
{
    class Yandex_Disk_Functions
    {
        private const string Token = "AgADAASAUssBGGAADSFfcRFRBurE1Rstu0WtsR7-d2";

        internal static async void UpLoad(string DiskPath, string LocalPath) =>
                await new DiskHttpApi(Token).Files.UploadFileAsync(DiskPath, false, LocalPath, CancellationToken.None);

        internal static async void DownLoad(string DiskPath, string LocalPath) => 
                await new DiskHttpApi(Token).Files.DownloadFileAsync(DiskPath, LocalPath);
    }
}