question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for moving directories

See original GitHub issue

I think the API should follow that for moving files.

  • MoveDirectoryToDirectory(directoryPath, targetDirectoryPath) - Moves an existing directory to a new location (e.g. Move “build/project” to “package” results in “build/” and “package/project”). Target location must exist but full path to target location (once combined with directoryPath) must not.
  • MoveDirectories(pattern, targetDirectoryPath) - Moves existing directories matching the specified patern to a new location. Actual move implementation as MoveDirectoryToDirectory.
  • MoveDirectories(directoryPaths, targetDirectoryPath) - Moves existing directories to a new location. Actual move implementation as MoveDirectoryToDirectory.
  • MoveDirectory(directoryPath, targetDirectoryPath) - Moves an existing directory to a new location, providing the option to specify a new directory name. Target location must not exist. (e.g. Move “build/project” to “package” results in “build/” and “package/” if “package” did not already exist and an error if it did, whereas move “build/project” to “package/project” results in “build/” and “package/project”).

I think the MoveDirectory API should only work for directories on the same volume. Alternatively, if we determine the targetDirectoryPath is on a different volume (not sure if there is an existing method for this?) then we could implement a method to create a new directory on the the target volume, move the files within that directory, recursively apply for any sub-directories, and then delete the source directory.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
daveaglickcommented, Oct 19, 2016

Going to submit a PR for this shortly. I’m only going to focus on the single MoveDirectory(DirectoryPath, DirectoryPath) alias. I agree with @RichiCoder1 that the other aliases performing multiple directory operations are troublesome.

As with File.Move(FilePath), I’ll create a Directory.Move(DirectoryPath) method to do the work that primarily defers to DirectoryInfo.MoveTo(string) so we’ll inherit it’s restrictions and semantics including the same volume restriction and the restriction on moving one directory on top of another.

0reactions
devleadcommented, Oct 20, 2016

Fixed by #1302

Read more comments on GitHub >

github_iconTop Results From Across the Web

Move your organization's content to shared drives
Move folders into shared drives as an admin · Sign in to your Google Admin console. · In the Admin console, go to...
Read more >
Redirect and move Windows known folders to OneDrive
In this article, you'll learn how to redirect users' Documents folders or other known folders to OneDrive.
Read more >
Move apps and create folders on your iPhone, iPad, or ...
Move apps and create folders on your iPhone, iPad, or iPod touch ... To make a folder, touch and hold an app until...
Read more >
Moving and Copying Files & Folders
Click anywhere in the row of the folder you want. The corresponding circle fills in, indicating your choice. Move.png. Click Move or click...
Read more >
Move Files (OSF Projects)
Select which folder you would like to move to. Click move to confirm the folder transfer. Your folder will now be inside a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found