trouble with system.io.file.copy 
Author Message
 trouble with system.io.file.copy

I am looking for a way to copy all the files in one directory to another
directory automatically
the problem im having is the file.copy method does not accept asterisks.
is there another command or way to copy all the files with out specifying
each name?

im using the following but it does not work
System.IO.File.Copy("c:\temp1\*.*","g:\staging\*.*", True)

any help would be greatly appreciated!!!

tony



Mon, 12 Sep 2005 05:06:20 GMT  
 trouble with system.io.file.copy
Here is a function that I am using...

Public Function CopyFolder(ByVal sFromFolder As String, _

        ByVal sTofolderUtil As String, _

        Optional ByVal sFilter As String = "*.*") As
Boolean

                Dim aFiles() As String
                Dim sFile As String
                Dim sfileName As String

                Dim aPath() As String
                Dim returnString As String

                'make sure the To folder is qualified -
 "/" on the end
                Dim qualTofolderUtil As String =
QualifyFolder(sTofolderUtil)

                Try
                        'get all files with the correct
extensions
                        aFiles = Directory.GetFiles
(sFromFolder, sFilter)
                        For Each sFile In aFiles
                                'get the filename and
extension
                                aPath = MSVB.Split
(sFile, "\")
                                sfileName = aPath
(aPath.Length - 1)
                                'copy each file over to
the new folder
                                File.Copy(sFile,
qualTofolderUtil & sfileName, True)
                                Application.DoEvents()
                        Next

                Catch ex As Exception
                        'MsgBox(ex.Message,
MsgBoxStyle.Exclamation, "Copy Folder Error")
                        Return False
                End Try

        End Function

hope it helps

Quote:
>-----Original Message-----
>I am looking for a way to copy all the files in one

directory to another
Quote:
>directory automatically
>the problem im having is the file.copy method does not
accept asterisks.
>is there another command or way to copy all the files
with out specifying
>each name?

>im using the following but it does not work
>System.IO.File.Copy("c:\temp1\*.*","g:\staging\*.*", True)

>any help would be greatly appreciated!!!

>tony

>.



Mon, 12 Sep 2005 06:43:02 GMT  
 trouble with system.io.file.copy
this helped a lot thanks.

Quote:
> Here is a function that I am using...

> Public Function CopyFolder(ByVal sFromFolder As String, _

> ByVal sTofolderUtil As String, _

> Optional ByVal sFilter As String = "*.*") As
> Boolean

> Dim aFiles() As String
> Dim sFile As String
> Dim sfileName As String

> Dim aPath() As String
> Dim returnString As String

> 'make sure the To folder is qualified -
>  "/" on the end
> Dim qualTofolderUtil As String =
> QualifyFolder(sTofolderUtil)

> Try
> 'get all files with the correct
> extensions
> aFiles = Directory.GetFiles
> (sFromFolder, sFilter)
> For Each sFile In aFiles
> 'get the filename and
> extension
> aPath = MSVB.Split
> (sFile, "\")
> sfileName = aPath
> (aPath.Length - 1)
> 'copy each file over to
> the new folder
> File.Copy(sFile,
> qualTofolderUtil & sfileName, True)
> Application.DoEvents()
> Next

> Catch ex As Exception
> 'MsgBox(ex.Message,
> MsgBoxStyle.Exclamation, "Copy Folder Error")
> Return False
> End Try

> End Function

> hope it helps

> >-----Original Message-----
> >I am looking for a way to copy all the files in one
> directory to another
> >directory automatically
> >the problem im having is the file.copy method does not
> accept asterisks.
> >is there another command or way to copy all the files
> with out specifying
> >each name?

> >im using the following but it does not work
> >System.IO.File.Copy("c:\temp1\*.*","g:\staging\*.*", True)

> >any help would be greatly appreciated!!!

> >tony

> >.



Tue, 13 Sep 2005 05:30:11 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How _copy_ a directory using System.IO

2. File locks when deleting files using SYSTEM.IO

3. File System Objects v. Open for file IO

4. Trouble Copying files

5. Trouble copying multiple files

6. Trouble Using ADSI To Copy File Permissions

7. Trouble with copying files over the network

8. System.IO.FileNotFoundException and imageupload

9. System.IO.FileNotFoundException

10. System.IO.StreamReader

11. How to use System.IO.Stream

12. System.IO.PathTooLongException

 

 
Powered by phpBB® Forum Software