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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. multiple file copies

multiple file copies

Scheduled Pinned Locked Moved Visual Basic
csharpquestion
4 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.
  • S Offline
    S Offline
    Serpent666
    wrote on last edited by
    #1

    if my vb.net form is trying to copy a file to a destination where the file already exists, how would i get it to rename the new file to something different? eg: if "C:\test.txt" exists then it will rename it to "C:\test01.txt" and if those two exist then it will rename it to "C:\test02.txt" so you could get "C:\test01.txt" "C:\test02.txt" "C:\test03.txt" "C:\test04.txt" .......... etc etc

    T 1 Reply Last reply
    0
    • S Serpent666

      if my vb.net form is trying to copy a file to a destination where the file already exists, how would i get it to rename the new file to something different? eg: if "C:\test.txt" exists then it will rename it to "C:\test01.txt" and if those two exist then it will rename it to "C:\test02.txt" so you could get "C:\test01.txt" "C:\test02.txt" "C:\test03.txt" "C:\test04.txt" .......... etc etc

      T Offline
      T Offline
      Tamimi Code
      wrote on last edited by
      #2

      hi search the destination for the file. i.e. if you are copying the file "C:\test.txt" user the following : System.IO.File.Exists("c:\test.txt") , this will return true if the files exist Tamimi - Code

      S 1 Reply Last reply
      0
      • T Tamimi Code

        hi search the destination for the file. i.e. if you are copying the file "C:\test.txt" user the following : System.IO.File.Exists("c:\test.txt") , this will return true if the files exist Tamimi - Code

        S Offline
        S Offline
        Serpent666
        wrote on last edited by
        #3

        already know that code, sorry but its not what im looking for im not looking for it to check for it and if its there then it will not copy im looking for code that if the file is there, it will rename it and send in the same file but rename it example: when you copy a file in windows and paste it a couple of times it will make copies like this Copy of Test Copy (2) of Test Copy (3) of Test etc etc im trying to make my program do that

        S 1 Reply Last reply
        0
        • S Serpent666

          already know that code, sorry but its not what im looking for im not looking for it to check for it and if its there then it will not copy im looking for code that if the file is there, it will rename it and send in the same file but rename it example: when you copy a file in windows and paste it a couple of times it will make copies like this Copy of Test Copy (2) of Test Copy (3) of Test etc etc im trying to make my program do that

          S Offline
          S Offline
          shreekar
          wrote on last edited by
          #4

          You will have to set up a loop that checks for existence of the file and rename it if necessary, like: Dim strExtnOnly as string = ".txt" Dim strFileNameOnly as string = "test" Dim blnDone as Boolean = false Dim strDest as string = "Your destination folder" dim intCounter as integer= 1 do while blnDone = false strFullPath = strDest & "/" strFileNameOnly & strExtnOnly if File.Exists(strFullPath) then intCounter+= intCounter strFileNameOnly = strFileNameOnly & CStr(intCounter.ToString.padleft("0",2)) ' something like that else blnDone=True end if loop HTH Shreekar http://shreekarishere.blogspot.com

          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