how to copy all files from one folder to another using system.io

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2007
Posts: 16
Reputation: rinkuchoudhury is an unknown quantity at this point 
Solved Threads: 0
rinkuchoudhury rinkuchoudhury is offline Offline
Newbie Poster

how to copy all files from one folder to another using system.io

 
0
  #1
Feb 24th, 2007
hi
I am working in asp.net,vb.net
I have to copy all files from 1 folder to another folder through coding using system.io

the files in the new folder should remain with the same name

how to do this.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 47
Reputation: kapil.goyal is an unknown quantity at this point 
Solved Threads: 0
kapil.goyal kapil.goyal is offline Offline
Light Poster

Re: how to copy all files from one folder to another using system.io

 
0
  #2
Feb 27th, 2007
For Each f In Directory.GetFiles(sourcefolderpath)

file.copy(f,destination path)
Next
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 3
Reputation: ajit2mail is an unknown quantity at this point 
Solved Threads: 0
ajit2mail ajit2mail is offline Offline
Newbie Poster

Re: how to copy all files from one folder to another using system.io

 
0
  #3
Aug 24th, 2008
thank you
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 3
Reputation: ajit2mail is an unknown quantity at this point 
Solved Threads: 0
ajit2mail ajit2mail is offline Offline
Newbie Poster

Re: how to copy all files from one folder to another using system.io

 
0
  #4
Dec 22nd, 2008
Originally Posted by rinkuchoudhury View Post
hi
I am working in asp.net,vb.net
I have to copy all files from 1 folder to another folder through coding using system.io

the files in the new folder should remain with the same name

how to do this.
--------------------------------------------------------------------------------

Here is VB code
  1. imports System.io
  2.  
  3. Public Shared Sub CopyFlashScriptFile(ByVal SourceDirectory As String, ByVal DestinationDirectory As String)
  4. Try
  5. Dim f() As String = Directory.GetFiles(SourceDirectory)
  6. For i As Integer = 0 To UBound(f)
  7. File.Copy(f(i), DestinationDirectory & "\" & fileNameWithoutThePath(f(i)))
  8. Next
  9. Catch ex As Exception
  10. End Try
  11. End Sub
  12.  
Last edited by peter_budo; Dec 29th, 2008 at 11:20 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the ASP.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC