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. Visual Basic
  4. how to rename a txt file VB.NET

how to rename a txt file VB.NET

Scheduled Pinned Locked Moved Visual Basic
csharptutorial
8 Posts 3 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.
  • U Offline
    U Offline
    User 2269706
    wrote on last edited by
    #1

    how to rename a txt file i am able to file, Create, Delete ,, but how to rename a txt file VB.NET

    S 1 Reply Last reply
    0
    • U User 2269706

      how to rename a txt file i am able to file, Create, Delete ,, but how to rename a txt file VB.NET

      S Offline
      S Offline
      sathish s
      wrote on last edited by
      #2

      File.Move("C:\Dir1\SomeFile.txt", "C:\Dir1\RenamedFileName.txt")

      U 1 Reply Last reply
      0
      • S sathish s

        File.Move("C:\Dir1\SomeFile.txt", "C:\Dir1\RenamedFileName.txt")

        U Offline
        U Offline
        User 2269706
        wrote on last edited by
        #3

        Thanks for ur responce I am vc++ programmer new to .net i did the same but I am getting exception The process cannot access the file because it is being used by another process... this is the code oFile1.Delete("C:\WINDOWS\Doctors.txt") System.IO.File.Move("C:\Windows\tempdoc.txt", "C:\Windows\Doctors1.txt") 'oFile1.Move("c:\Windows\tempdoc.txt", "C:\Windows\Doctors1.txt") even the both r giving the samte error Can you Please Advice me

        J S 2 Replies Last reply
        0
        • U User 2269706

          Thanks for ur responce I am vc++ programmer new to .net i did the same but I am getting exception The process cannot access the file because it is being used by another process... this is the code oFile1.Delete("C:\WINDOWS\Doctors.txt") System.IO.File.Move("C:\Windows\tempdoc.txt", "C:\Windows\Doctors1.txt") 'oFile1.Move("c:\Windows\tempdoc.txt", "C:\Windows\Doctors1.txt") even the both r giving the samte error Can you Please Advice me

          J Offline
          J Offline
          J4amieC
          wrote on last edited by
          #4

          If you have a reference to the file, you will have to call Dispose on it before you can rename/overwrite it. Also, please avoid using SMS Speak in the forums. Current blacklist svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour

          U 1 Reply Last reply
          0
          • U User 2269706

            Thanks for ur responce I am vc++ programmer new to .net i did the same but I am getting exception The process cannot access the file because it is being used by another process... this is the code oFile1.Delete("C:\WINDOWS\Doctors.txt") System.IO.File.Move("C:\Windows\tempdoc.txt", "C:\Windows\Doctors1.txt") 'oFile1.Move("c:\Windows\tempdoc.txt", "C:\Windows\Doctors1.txt") even the both r giving the samte error Can you Please Advice me

            S Offline
            S Offline
            sathish s
            wrote on last edited by
            #5

            This code works fine for me.. System.IO.File.Move("C:\Windows\tempdoc.txt", "C:\Windows\Doctors1.txt") 'The process cannot access the file because it is being used by another process' can be caused either a. tempdoc.txt is opened by some other application. b. tempdoc.txt is still open by your application and failed to close.

            U 1 Reply Last reply
            0
            • J J4amieC

              If you have a reference to the file, you will have to call Dispose on it before you can rename/overwrite it. Also, please avoid using SMS Speak in the forums. Current blacklist svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour

              U Offline
              U Offline
              User 2269706
              wrote on last edited by
              #6

              can u pls give me some example , delete file "a.txt" i need to rename a file rename "b.txt" as "a.txt", or overwite "a.txt" with "a.txt" oFile1.Delete("C:\WINDOWS\Doctors.txt") System.IO.File.Move("C:\Windows\tempdoc.txt", "C:\Windows\Doctors.txt") oFile1.Move -- modified at 5:52 Wednesday 7th June, 2006

              J 1 Reply Last reply
              0
              • S sathish s

                This code works fine for me.. System.IO.File.Move("C:\Windows\tempdoc.txt", "C:\Windows\Doctors1.txt") 'The process cannot access the file because it is being used by another process' can be caused either a. tempdoc.txt is opened by some other application. b. tempdoc.txt is still open by your application and failed to close.

                U Offline
                U Offline
                User 2269706
                wrote on last edited by
                #7

                Thanks u My dear Friend it my mistake!, I had not closed the file in overlook, and breaking my head from few hours Thanks a Lot Have a Nice day! Bye:) Understanding comes form failures Sucesses comes form Understanding failures -- modified at 5:59 Wednesday 7th June, 2006

                1 Reply Last reply
                0
                • U User 2269706

                  can u pls give me some example , delete file "a.txt" i need to rename a file rename "b.txt" as "a.txt", or overwite "a.txt" with "a.txt" oFile1.Delete("C:\WINDOWS\Doctors.txt") System.IO.File.Move("C:\Windows\tempdoc.txt", "C:\Windows\Doctors.txt") oFile1.Move -- modified at 5:52 Wednesday 7th June, 2006

                  J Offline
                  J Offline
                  J4amieC
                  wrote on last edited by
                  #8

                  ptr_Electron wrote:

                  can u pls

                  Can you please use full sentences in the forum, in oppose to SMS Speak. Current blacklist svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour

                  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