954,198 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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

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.

rinkuchoudhury
Newbie Poster
16 posts since Jan 2007
Reputation Points: 10
Solved Threads: 0
 

For Each f In Directory.GetFiles(sourcefolderpath)

file.copy(f,destination path)
Next

kapil.goyal
Light Poster
47 posts since Jan 2007
Reputation Points: 10
Solved Threads: 0
 

thank you

ajit2mail
Newbie Poster
3 posts since Jun 2008
Reputation Points: 10
Solved Threads: 0
 

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

imports System.io

  Public Shared Sub CopyFlashScriptFile(ByVal SourceDirectory As String, ByVal DestinationDirectory As String)
            Try
                Dim f() As String = Directory.GetFiles(SourceDirectory)
                For i As Integer = 0 To UBound(f)
                    File.Copy(f(i), DestinationDirectory & "\" & fileNameWithoutThePath(f(i)))
                Next
            Catch ex As Exception
            End Try
    End Sub
ajit2mail
Newbie Poster
3 posts since Jun 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You