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. Web Development
  3. ASP.NET
  4. Copy file from from one folder to another folder with rename

Copy file from from one folder to another folder with rename

Scheduled Pinned Locked Moved ASP.NET
csharp
4 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.
  • H Offline
    H Offline
    Hemant_ec48
    wrote on last edited by
    #1

    Hi. i have one folder ABC --1.txt --2.txt I have to copy this file to another folder XYZ --11.txt --12.txt how can achive this task in vb.net.... Regards, Hemant Patel.

    C A A 3 Replies Last reply
    0
    • H Hemant_ec48

      Hi. i have one folder ABC --1.txt --2.txt I have to copy this file to another folder XYZ --11.txt --12.txt how can achive this task in vb.net.... Regards, Hemant Patel.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      This question has NOTHING to do with ASP.NET

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      1 Reply Last reply
      0
      • H Hemant_ec48

        Hi. i have one folder ABC --1.txt --2.txt I have to copy this file to another folder XYZ --11.txt --12.txt how can achive this task in vb.net.... Regards, Hemant Patel.

        A Offline
        A Offline
        Abhishek Sur
        wrote on last edited by
        #3

        You mean both the folders in the server ??? If so, why dont you use File.Copy(path1,path2) :thumbsup::thumbsup:

        Abhishek Sur


        My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

        **Don't forget to click "Good Answer" if you like to.

        1 Reply Last reply
        0
        • H Hemant_ec48

          Hi. i have one folder ABC --1.txt --2.txt I have to copy this file to another folder XYZ --11.txt --12.txt how can achive this task in vb.net.... Regards, Hemant Patel.

          A Offline
          A Offline
          Abhijit Jana
          wrote on last edited by
          #4

          Hemant_ec48 wrote:

          how can achive this task in vb.net....

          Here is the way.

          using System.IO

          Public Sub CopyDir(ByVal strSrc As String, ByVal strDest As String)
          Dim dirInfo As New DirectoryInfo(strSrc)
          Dim fsInfo As FileSystemInfo
          If Not Directory.Exists(strDest) Then
          Directory.CreateDirectory(strDest)
          End If
          For Each fsInfo In dirInfo.GetFileSystemInfos
          Dim strDestFileName As String = Path.Combine(strDest, fsInfo.Name)
          If TypeOf fsInfo Is FileInfo Then
          File.Copy(fsInfo.FullName, strDestFileName, True)
          'This will overwrite files that already exist
          Else
          CopyDir(fsInfo.FullName, strDestFileName)
          End If
          Next
          End Sub

          But,as CG suggested this has nothing to with ASP.NET. You should always ask the question in proper fourm to get the better answer. Thanks !

          Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

          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