cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Are you interested in learning how media industry leaders use Dropbox Replay? Register for our webinar here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to merge two folders with Dropbox.Net SDK?

How to merge two folders with Dropbox.Net SDK?

XiangZhou
New member | Level 2

Dear support, 

 

To rename a folder, I call the MoveV2Async(pathOld, pathNew). 

If the pathNew exists, it fails with an error "to/conflict/folder/". 

 

If the destination folder already exists, I'd like to merge the old folder including its contained files/subfolders to the destination folder. 

i.e. copy and replace the files/subfolders if they exist.  Is it possible? 

 

It seems to me that the three optional parameters in MoveV2Async are not for this purpose. Any other methods I can use?

 

Thanks 

 

Xiang 

6 Replies 6

Здравко
Legendary | Level 20

Hi @XiangZhou,

As seems, there is no option to 'merge' files/folders using move by now. What you can do depends on what exactly you want achieve. If you just want to replace the existing folder, it becomes easy - delete the existing folder and move there the desired one (on the follow up try, after the remove). In such a way entire content of existing folder will gone (doesn't matter are there parts that don't overlap). If you want to keep non overlapping parts, you have to implement recursive algorithm that walk through the folder tree of the source folder and perform try move (eventually followed by delete and move) for files only. At the end, you'll need remove the source folder (there will be eventually empty subfolders only). If you want to merge files content further, then some content specific algorithms will also need as a part of the recursion.

Hope this gives direction.

Greg-DB
Dropbox Staff

@XiangZhou Здравко is correct; the Dropbox API doesn't offer a way to merge folders like this directly, but I'll pass this along as a feature request. I can't promise if or when that might be implemented though. You'd need to handle this in your code like they described. If/when you need to move multiple items, using MoveBatchAsync can help.

XiangZhou
New member | Level 2

Thanks for your suggestion. 

 

I am trying to implement it manually by deleting files in the destination folder firstly if exist and then move the files. 

 

After calling the DeleteBatchV2Async, how do I safely wait until the files have been completely deleted before calling the  MoveBatchAsync. Could you show me some sample code?   

Greg-DB
Dropbox Staff

I don't believe we have sample code for DeleteBatchAsync in particular unfortunately, but you should poll DeleteBatchCheckAsync to see when the job is done. Refer to the documentation linked there for more information.

 

By the way, it looks like you mixed up DeleteBatchAsync with DeleteV2Async or MoveBatchV2Async; there's no DeleteBatchV2Async.

DCProducer
New member | Level 2

Has there been any progress on this? I've accidently created a duplicate of a large folder  and have been adding to both without realizing my error. I want to now merge without fear of losing something. Is this possible within Dropbox or some additional software/app?  Thank you!

Greg-DB
Dropbox Staff

@DCProducer No, I don't have an update on this feature request for the Dropbox API.

 

Note that this thread is regarding some functionality for the Dropbox API for use by developers. It's possible someone has already developed an app as a solution for this scenario, but unfortunately I can't offer guidance on third party apps like that.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    DCProducer New member | Level 2
  • User avatar
    XiangZhou New member | Level 2
What do Dropbox user levels mean?