ItemExtension STATIC CLASS

An extension class for System.IO.Item that adds shared methods applicable to both file and directory.

Parent Class

All Members


TypeNameSignature
method Srelocatepublic static bool relocate(System.IO.Item, System.IO.Directory, string)

Methods


public static bool relocate(Item this, Directory newDir, string newName)

Move this item to another directory and rename it.

This is a convenient method that wraps the functionality of move() and rename() together. It is not a transactional operation. It may fail halfway leaving a moved item yet to be renamed, although it will try its best to restore to the previous status.

Parameters

  • this The extension target.
  • newDir The new directory.
  • newName The new item name. Must not contain FS separator.

Returns

  • True if the item was successfully moved and renamed; false if it couldn't be and no change has occurred.

Throws

  • System.IO.IOException An error occurred during the underlying file system operation. In particular, this exception is thrown when we moved the item but failed to rename it, and a restoration (move-back) attempt was also foiled.