SharpAdb / AdvancedSharpAdbClient

AdvancedSharpAdbClient is a .NET library that allows .NET, Mono and Unity applications to communicate with Android devices. It's improved version of SharpAdbClient.
https://sharpadb.github.io
Apache License 2.0
201 stars 54 forks source link

Pushing/pulling files from the device #96

Open itapi opened 8 months ago

itapi commented 8 months ago

What can we do for you?

I'm using the following code:

void DownloadFile()
{
    using (SyncService service = new SyncService(device))
    {
        string path = Environment.CurrentDirectory + @"\test.txt";
        using (FileStream stream = File.OpenWrite(path))
        {
            service.PullAsync("/data/local/tmp/a.txt", stream, null);
        }
    }
}

void UploadFile()
{
    using (SyncService service = new SyncService(device))
    {
        string path = Environment.CurrentDirectory + @"\test.txt";
        using (FileStream stream = File.OpenRead(path))
        {
            service.PushAsync(stream, "/data/local/tmp/a.txt", 777, DateTimeOffset.Now, null);
        }
    }
}

But nothing happends... Neither the "UploadFile" method works, nor the other. What I'm doing wrong..?

wherewhere commented 8 months ago

You never await your task. So your service just disposed after it gone...