Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Rename a file from his String Path [Resolved]

Rename a file from his String Path [Resolved]

Scheduled Pinned Locked Moved C#
questionhelp
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pierre besquent
    wrote on last edited by
    #1

    Hi guys, How can I rename my file defined by my string Path? I want to pass from : TXTFile_rfcyxt55efrem1fj4sycjv5527-04-2011_17h-4641_0.txt to Entite1.txt ty for u help

    modified on Thursday, April 28, 2011 4:47 AM

    G 1 Reply Last reply
    0
    • P Pierre besquent

      Hi guys, How can I rename my file defined by my string Path? I want to pass from : TXTFile_rfcyxt55efrem1fj4sycjv5527-04-2011_17h-4641_0.txt to Entite1.txt ty for u help

      modified on Thursday, April 28, 2011 4:47 AM

      G Offline
      G Offline
      Groulien
      wrote on last edited by
      #2

      Renaming works the same as moving.

      File.Move("TXTFile_rfcyxt55efrem1fj4sycjv5527-04-2011_17h-4641_0.txt", "Entite1.txt");

      See also: http://msdn.microsoft.com/en-us/library/system.io.file.move.aspx[^]

      P 1 Reply Last reply
      0
      • G Groulien

        Renaming works the same as moving.

        File.Move("TXTFile_rfcyxt55efrem1fj4sycjv5527-04-2011_17h-4641_0.txt", "Entite1.txt");

        See also: http://msdn.microsoft.com/en-us/library/system.io.file.move.aspx[^]

        P Offline
        P Offline
        Pierre besquent
        wrote on last edited by
        #3

        Hi, File.Move is good solution also File.CopyTo(olderpath, NewPath) is also well working) Ty

        A 1 Reply Last reply
        0
        • P Pierre besquent

          Hi, File.Move is good solution also File.CopyTo(olderpath, NewPath) is also well working) Ty

          A Offline
          A Offline
          ambarishtv
          wrote on last edited by
          #4

          file raname using Regex like this newfilename = Regex.Replace(fDialog.FileName, "F.NCF", "H.NCF");

          -ambarish-

          P 1 Reply Last reply
          0
          • A ambarishtv

            file raname using Regex like this newfilename = Regex.Replace(fDialog.FileName, "F.NCF", "H.NCF");

            -ambarish-

            P Offline
            P Offline
            Pete OHanlon
            wrote on last edited by
            #5

            That just changes strings. It doesn't touch the file at all.

            Forgive your enemies - it messes with their heads

            My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups