Add support for moving directories
See original GitHub issueI 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:
- Created 8 years ago
- Comments:6 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 aDirectory.Move(DirectoryPath)
method to do the work that primarily defers toDirectoryInfo.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.Fixed by #1302