Skip to content

Pulling folder content  #98

Open
Open
@itapi

Description

@itapi

What can we do for you?

this is my code to pull the dcim image on the android main storage:

async Task DownloadFiles()
{
   SyncService service = new SyncService(device);

   string folderPath = Environment.CurrentDirectory + "/downloaded_files";

   // Ensure the target folder exists, create it if needed
   if (!Directory.Exists(folderPath))
   {
       Directory.CreateDirectory(folderPath);
   }

   string source = "/sdcard/dcim";
   var files = await service.GetDirectoryListingAsync(source);

   // Download each file and save it to the local folder
   foreach (var file in files)
   {
       service = new SyncService(device);

       string localFilePath = Path.Combine(folderPath, file.Path);

       using (FileStream stream = File.OpenWrite(localFilePath))
       {
           string path = source + "/" + file.Path;        
           await service.PullAsync(path, stream);
       }
   }
}

I'm getting this error:
Failed to pull '/sdcard/dcim/Camera'. read failed: Is a directory

I can't specify in advance the full path, "/sdcard/dcim/camera" because my program need to pull the entire "dcim" content,and it might be dynamic content,and contain many other folders inside....is there any way to pull is like using the simple shell command "adb pull /sdcard/dcim"(which would do the work perfectly)?
Thanks in advance guys!

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions