Copy files from one folder to another
-
I need to copy all files from one file to another..Could someon help
-
I need to copy all files from one file to another..Could someon help
check System.IO.Directory.GetFiles() System.IO.File.Copy()
When you get mad...THINK twice that the only advice Tamimi - Code
-
I need to copy all files from one file to another..Could someon help
If you're using VB.NET 2005, you can use that handly little "My":
For Each sfile As String In My.Computer.FileSystem.GetFiles( My.Computer.FileSystem.SpecialDirectories.MyDocuments,FileIO.SearchOption.SearchAllSubDirectories,"*.*") My.Computer.FileSystem.CopyFile(sFile, "C:\Lalala") Next
me, myself and my blog - loadx.org ericos g.
-
If you're using VB.NET 2005, you can use that handly little "My":
For Each sfile As String In My.Computer.FileSystem.GetFiles( My.Computer.FileSystem.SpecialDirectories.MyDocuments,FileIO.SearchOption.SearchAllSubDirectories,"*.*") My.Computer.FileSystem.CopyFile(sFile, "C:\Lalala") Next
me, myself and my blog - loadx.org ericos g.
Could you please explain wat is going on
-
Could you please explain wat is going on
sure :) to find all the files in a folder, and do something with each file (like copy them) i used the "For Each" statement.
For Each sfile As String In My.Computer.FileSystem.GetFiles( ..
so sfile is a string with all the filenames located in the specified folder (in my case, My Documents)My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.SpecialDirectories.MyDocuments, FileIO.SearchOption.SearchAllSubDirectories, "*.*")
or could be anything, likeMy.Computer.FileSystem.GetFiles("C:\Tatata")
then each file was given the command to be copied to "C:\Lalala"My.Computer.FileSystem.CopyFile(sFile, "C:\Lalala")
and then ends the loop:Next
i hope that helps.me, myself and my blog - loadx.org ericos g.
-
sure :) to find all the files in a folder, and do something with each file (like copy them) i used the "For Each" statement.
For Each sfile As String In My.Computer.FileSystem.GetFiles( ..
so sfile is a string with all the filenames located in the specified folder (in my case, My Documents)My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.SpecialDirectories.MyDocuments, FileIO.SearchOption.SearchAllSubDirectories, "*.*")
or could be anything, likeMy.Computer.FileSystem.GetFiles("C:\Tatata")
then each file was given the command to be copied to "C:\Lalala"My.Computer.FileSystem.CopyFile(sFile, "C:\Lalala")
and then ends the loop:Next
i hope that helps.me, myself and my blog - loadx.org ericos g.
Thanks a lot....That was my requirement i will try it outt
-
I need to copy all files from one file to another..Could someon help
This Function can do for u !!!! :laugh::laugh: Imports 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 While Copying , if the source dir content large file your GUI will be hanged,,,, so u can use Background worker along with that methods
Happy Programming ----- Abhijit
-
This Function can do for u !!!! :laugh::laugh: Imports 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 While Copying , if the source dir content large file your GUI will be hanged,,,, so u can use Background worker along with that methods
Happy Programming ----- Abhijit
This works perfectly fine...Thanks a lot