Rename and Replace file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shapper

    Rename and Replace file

    Hello,

    I am moving file from a folder A to folder B using:

    System.IO.File. Move(path, newpath)

    I am not sure if this is the best way to do this but I also need to:

    1. Rename the file before coping it (I want to keep the extension. I
    just want to rename the filename)

    2. If the file already exists in the new path I want it to be
    replaced.

    How can I do this?

    Thanks,

    Miguel
  • =?Utf-8?B?WmVlc2hhbiBIYWlkZXI=?=

    #2
    RE: Rename and Replace file

    You can use the FileInfo.MoveTo () method. This method moves a specified file
    to a new location, providing the option to specify a new file name.

    "shapper" wrote:
    Hello,
    >
    I am moving file from a folder A to folder B using:
    >
    System.IO.File. Move(path, newpath)
    >
    I am not sure if this is the best way to do this but I also need to:
    >
    1. Rename the file before coping it (I want to keep the extension. I
    just want to rename the filename)
    >
    2. If the file already exists in the new path I want it to be
    replaced.
    >
    How can I do this?
    >
    Thanks,
    >
    Miguel
    >

    Comment

    Working...