|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Copy DirectoryI found a real nice article on how to copy a directory on MSDN. The
only problem is that I can not figure out how to get the namespace Microsoft.VisualBasic.MyServices. I wanted to know if anyone else has had experience with this, or knows of a different way to copy a directory using VB. I found ways to copy files, but not having a lot of luck with finding a way to copy a directory other then this information I am finding on MSDN. Thanks Scott Moore I found my error, it is for 2.0. I need to upgrade to 2.0 to get it to
work. samoore33 wrote: Show quoteHide quote > I found a real nice article on how to copy a directory on MSDN. The > only problem is that I can not figure out how to get the namespace > Microsoft.VisualBasic.MyServices. I wanted to know if anyone else has > had experience with this, or knows of a different way to copy a > directory using VB. > > I found ways to copy files, but not having a lot of luck with finding a > way to copy a directory other then this information I am finding on > MSDN. > > Thanks > > Scott Moore Or use just System.IO.Directory... Some of the 2.0 My features are just
wrappers around the .NET framework classes available elsewhere... -- Patrice "samoore33" <samoor***@gmail.com> a écrit dans le message de news: 1159193714.223834.153***@m7g2000cwm.googlegroups.com...Show quoteHide quote >I found my error, it is for 2.0. I need to upgrade to 2.0 to get it to > work. > > samoore33 wrote: >> I found a real nice article on how to copy a directory on MSDN. The >> only problem is that I can not figure out how to get the namespace >> Microsoft.VisualBasic.MyServices. I wanted to know if anyone else has >> had experience with this, or knows of a different way to copy a >> directory using VB. >> >> I found ways to copy files, but not having a lot of luck with finding a >> way to copy a directory other then this information I am finding on >> MSDN. >> >> Thanks >> >> Scott Moore > In the System.IO.Directory I can only find Move. I do not see where I
can copy a directory. The Move works, but it cuts the directory, it does not copy it. Scott Patrice wrote: Show quoteHide quote > Or use just System.IO.Directory... Some of the 2.0 My features are just > wrappers around the .NET framework classes available elsewhere... > > -- > Patrice > > "samoore33" <samoor***@gmail.com> a écrit dans le message de news: > 1159193714.223834.153***@m7g2000cwm.googlegroups.com... > >I found my error, it is for 2.0. I need to upgrade to 2.0 to get it to > > work. > > > > samoore33 wrote: > >> I found a real nice article on how to copy a directory on MSDN. The > >> only problem is that I can not figure out how to get the namespace > >> Microsoft.VisualBasic.MyServices. I wanted to know if anyone else has > >> had experience with this, or knows of a different way to copy a > >> directory using VB. > >> > >> I found ways to copy files, but not having a lot of luck with finding a > >> way to copy a directory other then this information I am finding on > >> MSDN. > >> > >> Thanks > >> > >> Scott Moore > > Scott,
You may or may not like this method, but I thought I'd post it anyway. You could use xcopy in a .bat file to copy the directory from one location to another. Using different switches for xcopy you can include hidden files, subdirectories, ignore errors, automatically create subdirectories, turn message prompts off and a bunch of other options. Here is a complete list of switch options for xcopy: http://www.computerhope.com/xcopyhlp.htm You could call this .bat file using System.Diagnostics.Process.Start([Path To .bat File]) I think you should be able to hide the command window from showing up. By starting a new process you would be able to tell when the process finishes. Additionally you could modify the .bat file in the future so code changes would not be necessary. Just a thought, Izzy samoore33 wrote: Show quoteHide quote > I found a real nice article on how to copy a directory on MSDN. The > only problem is that I can not figure out how to get the namespace > Microsoft.VisualBasic.MyServices. I wanted to know if anyone else has > had experience with this, or knows of a different way to copy a > directory using VB. > > I found ways to copy files, but not having a lot of luck with finding a > way to copy a directory other then this information I am finding on > MSDN. > > Thanks > > Scott Moore I had used a bat file before, but had not thought of calling it through
code. Thanks for the idea. Scott Izzy wrote: Show quoteHide quote > Scott, > > You may or may not like this method, but I thought I'd post it anyway. > > You could use xcopy in a .bat file to copy the directory from one > location to another. Using different switches for xcopy you can include > hidden files, subdirectories, ignore errors, automatically create > subdirectories, turn message prompts off and a bunch of other options. > Here is a complete list of switch options for xcopy: > > http://www.computerhope.com/xcopyhlp.htm > > You could call this .bat file using > System.Diagnostics.Process.Start([Path To .bat File]) > I think you should be able to hide the command window from showing up. > > By starting a new process you would be able to tell when the process > finishes. Additionally you could modify the .bat file in the future so > code changes would not be necessary. > > Just a thought, > Izzy > > samoore33 wrote: > > I found a real nice article on how to copy a directory on MSDN. The > > only problem is that I can not figure out how to get the namespace > > Microsoft.VisualBasic.MyServices. I wanted to know if anyone else has > > had experience with this, or knows of a different way to copy a > > directory using VB. > > > > I found ways to copy files, but not having a lot of luck with finding a > > way to copy a directory other then this information I am finding on > > MSDN. > > > > Thanks > > > > Scott Moore I am trying to use the XCOPY command in a batch file. This is what I am
trying to do. @echo off XCOPY C:\Pictures C:\Documents and Settings\smoore\My Documents\Pictures Pause When I run this I get Invalid number of parameters? Not sure what I am doing wrong here, please advise. Scott Izzy wrote: Show quoteHide quote > Scott, > > You may or may not like this method, but I thought I'd post it anyway. > > You could use xcopy in a .bat file to copy the directory from one > location to another. Using different switches for xcopy you can include > hidden files, subdirectories, ignore errors, automatically create > subdirectories, turn message prompts off and a bunch of other options. > Here is a complete list of switch options for xcopy: > > http://www.computerhope.com/xcopyhlp.htm > > You could call this .bat file using > System.Diagnostics.Process.Start([Path To .bat File]) > I think you should be able to hide the command window from showing up. > > By starting a new process you would be able to tell when the process > finishes. Additionally you could modify the .bat file in the future so > code changes would not be necessary. > > Just a thought, > Izzy > > samoore33 wrote: > > I found a real nice article on how to copy a directory on MSDN. The > > only problem is that I can not figure out how to get the namespace > > Microsoft.VisualBasic.MyServices. I wanted to know if anyone else has > > had experience with this, or knows of a different way to copy a > > directory using VB. > > > > I found ways to copy files, but not having a lot of luck with finding a > > way to copy a directory other then this information I am finding on > > MSDN. > > > > Thanks > > > > Scott Moore Try This:
XCOPY C:\Pictures "C:\Documents and Settings\smoore\My Documents \Pictures" Show quoteHide quote "samoore33" <samoor***@gmail.com> wrote in news:1159204857.783458.99180@k70g2000cwa.googlegroups.com: > I am trying to use the XCOPY command in a batch file. This is what I > am trying to do. > > @echo off > > XCOPY C:\Pictures C:\Documents and Settings\smoore\My > Documents\Pictures > > Pause > > When I run this I get Invalid number of parameters? > > Not sure what I am doing wrong here, please advise. > > Scott > > Izzy wrote: >> Scott, >> >> You may or may not like this method, but I thought I'd post it >> anyway. >> >> You could use xcopy in a .bat file to copy the directory from one >> location to another. Using different switches for xcopy you can >> include hidden files, subdirectories, ignore errors, automatically >> create subdirectories, turn message prompts off and a bunch of other >> options. Here is a complete list of switch options for xcopy: >> >> http://www.computerhope.com/xcopyhlp.htm >> >> You could call this .bat file using >> System.Diagnostics.Process.Start([Path To .bat File]) >> I think you should be able to hide the command window from showing >> up. >> >> By starting a new process you would be able to tell when the process >> finishes. Additionally you could modify the .bat file in the future >> so code changes would not be necessary. >> >> Just a thought, >> Izzy >> >> samoore33 wrote: >> > I found a real nice article on how to copy a directory on MSDN. The >> > only problem is that I can not figure out how to get the namespace >> > Microsoft.VisualBasic.MyServices. I wanted to know if anyone else >> > has had experience with this, or knows of a different way to copy a >> > directory using VB. >> > >> > I found ways to copy files, but not having a lot of luck with >> > finding a way to copy a directory other then this information I am >> > finding on MSDN. >> > >> > Thanks >> > >> > Scott Moore > Try this:
XCOPY C:\Pictures "C:\Documents and Settings\smoore\My Documents\Pictures" /e /c /i /h /k This issus is you didn't enclose the path with spaces in quatation marks. Look at the link I sent too see what the switches mean. Izzy samoore33 wrote: Show quoteHide quote > I am trying to use the XCOPY command in a batch file. This is what I am > trying to do. > > @echo off > > XCOPY C:\Pictures C:\Documents and Settings\smoore\My > Documents\Pictures > > Pause > > When I run this I get Invalid number of parameters? > > Not sure what I am doing wrong here, please advise. > > Scott > > Izzy wrote: > > Scott, > > > > You may or may not like this method, but I thought I'd post it anyway. > > > > You could use xcopy in a .bat file to copy the directory from one > > location to another. Using different switches for xcopy you can include > > hidden files, subdirectories, ignore errors, automatically create > > subdirectories, turn message prompts off and a bunch of other options. > > Here is a complete list of switch options for xcopy: > > > > http://www.computerhope.com/xcopyhlp.htm > > > > You could call this .bat file using > > System.Diagnostics.Process.Start([Path To .bat File]) > > I think you should be able to hide the command window from showing up. > > > > By starting a new process you would be able to tell when the process > > finishes. Additionally you could modify the .bat file in the future so > > code changes would not be necessary. > > > > Just a thought, > > Izzy > > > > samoore33 wrote: > > > I found a real nice article on how to copy a directory on MSDN. The > > > only problem is that I can not figure out how to get the namespace > > > Microsoft.VisualBasic.MyServices. I wanted to know if anyone else has > > > had experience with this, or knows of a different way to copy a > > > directory using VB. > > > > > > I found ways to copy files, but not having a lot of luck with finding a > > > way to copy a directory other then this information I am finding on > > > MSDN. > > > > > > Thanks > > > > > > Scott Moore Thanks a lot Izzy, it is working now.
Izzy wrote: Show quoteHide quote > Try this: > > XCOPY C:\Pictures "C:\Documents and Settings\smoore\My > Documents\Pictures" /e /c /i /h /k > > This issus is you didn't enclose the path with spaces in quatation > marks. Look at the link I sent too see what the switches mean. > > Izzy > > > samoore33 wrote: > > I am trying to use the XCOPY command in a batch file. This is what I am > > trying to do. > > > > @echo off > > > > XCOPY C:\Pictures C:\Documents and Settings\smoore\My > > Documents\Pictures > > > > Pause > > > > When I run this I get Invalid number of parameters? > > > > Not sure what I am doing wrong here, please advise. > > > > Scott > > > > Izzy wrote: > > > Scott, > > > > > > You may or may not like this method, but I thought I'd post it anyway. > > > > > > You could use xcopy in a .bat file to copy the directory from one > > > location to another. Using different switches for xcopy you can include > > > hidden files, subdirectories, ignore errors, automatically create > > > subdirectories, turn message prompts off and a bunch of other options. > > > Here is a complete list of switch options for xcopy: > > > > > > http://www.computerhope.com/xcopyhlp.htm > > > > > > You could call this .bat file using > > > System.Diagnostics.Process.Start([Path To .bat File]) > > > I think you should be able to hide the command window from showing up. > > > > > > By starting a new process you would be able to tell when the process > > > finishes. Additionally you could modify the .bat file in the future so > > > code changes would not be necessary. > > > > > > Just a thought, > > > Izzy > > > > > > samoore33 wrote: > > > > I found a real nice article on how to copy a directory on MSDN. The > > > > only problem is that I can not figure out how to get the namespace > > > > Microsoft.VisualBasic.MyServices. I wanted to know if anyone else has > > > > had experience with this, or knows of a different way to copy a > > > > directory using VB. > > > > > > > > I found ways to copy files, but not having a lot of luck with finding a > > > > way to copy a directory other then this information I am finding on > > > > MSDN. > > > > > > > > Thanks > > > > > > > > Scott Moore Why can't you write a simple routine to copy all the files in your source
directory to your new directory using the copy method of the file class. -- Show quoteHide quoteDennis in Houston "samoore33" wrote: > Thanks a lot Izzy, it is working now. > > Izzy wrote: > > Try this: > > > > XCOPY C:\Pictures "C:\Documents and Settings\smoore\My > > Documents\Pictures" /e /c /i /h /k > > > > This issus is you didn't enclose the path with spaces in quatation > > marks. Look at the link I sent too see what the switches mean. > > > > Izzy > > > > > > samoore33 wrote: > > > I am trying to use the XCOPY command in a batch file. This is what I am > > > trying to do. > > > > > > @echo off > > > > > > XCOPY C:\Pictures C:\Documents and Settings\smoore\My > > > Documents\Pictures > > > > > > Pause > > > > > > When I run this I get Invalid number of parameters? > > > > > > Not sure what I am doing wrong here, please advise. > > > > > > Scott > > > > > > Izzy wrote: > > > > Scott, > > > > > > > > You may or may not like this method, but I thought I'd post it anyway. > > > > > > > > You could use xcopy in a .bat file to copy the directory from one > > > > location to another. Using different switches for xcopy you can include > > > > hidden files, subdirectories, ignore errors, automatically create > > > > subdirectories, turn message prompts off and a bunch of other options. > > > > Here is a complete list of switch options for xcopy: > > > > > > > > http://www.computerhope.com/xcopyhlp.htm > > > > > > > > You could call this .bat file using > > > > System.Diagnostics.Process.Start([Path To .bat File]) > > > > I think you should be able to hide the command window from showing up. > > > > > > > > By starting a new process you would be able to tell when the process > > > > finishes. Additionally you could modify the .bat file in the future so > > > > code changes would not be necessary. > > > > > > > > Just a thought, > > > > Izzy > > > > > > > > samoore33 wrote: > > > > > I found a real nice article on how to copy a directory on MSDN. The > > > > > only problem is that I can not figure out how to get the namespace > > > > > Microsoft.VisualBasic.MyServices. I wanted to know if anyone else has > > > > > had experience with this, or knows of a different way to copy a > > > > > directory using VB. > > > > > > > > > > I found ways to copy files, but not having a lot of luck with finding a > > > > > way to copy a directory other then this information I am finding on > > > > > MSDN. > > > > > > > > > > Thanks > > > > > > > > > > Scott Moore > > I was thinking the same thing, why not just write a recursive function to do
it for you. It isn't difficult. Hope this helps Greetz, Peter See sample code below. Private Sub DirectoryCopy(ByVal src As String, ByVal dest As String) If Not Directory.Exists(dest) Then Directory.CreateDirectory(dest) End If If Directory.Exists(src) And Directory.Exists(dest) Then Dim di As New DirectoryInfo(src) Dim fsi As FileSystemInfo For Each fsi In di.GetFileSystemInfos() Try Dim destName As String = Path.Combine(dest, fsi.Name) If TypeOf fsi Is FileInfo Then If fsi.Attributes = FileAttributes.ReadOnly Then fsi.Attributes = FileAttributes.Normal End If File.Copy(fsi.FullName, destName, True) Else Directory.CreateDirectory(destName) DirectoryCopy(fsi.FullName, destName) End If Catch ex As Exception MessageBox.Show(ex.ToString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try Next Else MessageBox.Show("Source or target doesn't exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End If End Sub -- Show quoteHide quoteProgramming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. (Rich Cook) "Dennis" <Den***@discussions.microsoft.com> schreef in bericht news:D4679DD8-C054-4696-9BF7-6BF64C4E906F@microsoft.com... > Why can't you write a simple routine to copy all the files in your source > directory to your new directory using the copy method of the file class. > -- > Dennis in Houston > > > "samoore33" wrote: > > > Thanks a lot Izzy, it is working now. > > > > Izzy wrote: > > > Try this: > > > > > > XCOPY C:\Pictures "C:\Documents and Settings\smoore\My > > > Documents\Pictures" /e /c /i /h /k > > > > > > This issus is you didn't enclose the path with spaces in quatation > > > marks. Look at the link I sent too see what the switches mean. > > > > > > Izzy > > > > > > > > > samoore33 wrote: > > > > I am trying to use the XCOPY command in a batch file. This is what I am > > > > trying to do. > > > > > > > > @echo off > > > > > > > > XCOPY C:\Pictures C:\Documents and Settings\smoore\My > > > > Documents\Pictures > > > > > > > > Pause > > > > > > > > When I run this I get Invalid number of parameters? > > > > > > > > Not sure what I am doing wrong here, please advise. > > > > > > > > Scott > > > > > > > > Izzy wrote: > > > > > Scott, > > > > > > > > > > You may or may not like this method, but I thought I'd post it anyway. > > > > > > > > > > You could use xcopy in a .bat file to copy the directory from one > > > > > location to another. Using different switches for xcopy you can include > > > > > hidden files, subdirectories, ignore errors, automatically create > > > > > subdirectories, turn message prompts off and a bunch of other options. > > > > > Here is a complete list of switch options for xcopy: > > > > > > > > > > http://www.computerhope.com/xcopyhlp.htm > > > > > > > > > > You could call this .bat file using > > > > > System.Diagnostics.Process.Start([Path To .bat File]) > > > > > I think you should be able to hide the command window from showing up. > > > > > > > > > > By starting a new process you would be able to tell when the process > > > > > finishes. Additionally you could modify the .bat file in the future so > > > > > code changes would not be necessary. > > > > > > > > > > Just a thought, > > > > > Izzy > > > > > > > > > > samoore33 wrote: > > > > > > I found a real nice article on how to copy a directory on MSDN. The > > > > > > only problem is that I can not figure out how to get the namespace > > > > > > Microsoft.VisualBasic.MyServices. I wanted to know if anyone else has > > > > > > had experience with this, or knows of a different way to copy a > > > > > > directory using VB. > > > > > > > > > > > > I found ways to copy files, but not having a lot of luck with finding a > > > > > > way to copy a directory other then this information I am finding on > > > > > > MSDN. > > > > > > > > > > > > Thanks > > > > > > > > > > > > Scott Moore > > > > Thanks for the code Peter, I'll archive it for later.
I think I still favor the xcopy method only because it's simple and achives the same result. Izzy Peter Proost wrote: Show quoteHide quote > I was thinking the same thing, why not just write a recursive function to do > it for you. It isn't difficult. > > Hope this helps > Greetz, Peter > > See sample code below. > > Private Sub DirectoryCopy(ByVal src As String, ByVal dest As String) > > If Not Directory.Exists(dest) Then > Directory.CreateDirectory(dest) > End If > > If Directory.Exists(src) And Directory.Exists(dest) Then > > Dim di As New DirectoryInfo(src) > Dim fsi As FileSystemInfo > > For Each fsi In di.GetFileSystemInfos() > Try > Dim destName As String = Path.Combine(dest, fsi.Name) > If TypeOf fsi Is FileInfo Then > If fsi.Attributes = FileAttributes.ReadOnly Then > fsi.Attributes = FileAttributes.Normal > End If > File.Copy(fsi.FullName, destName, True) > Else > Directory.CreateDirectory(destName) > DirectoryCopy(fsi.FullName, destName) > End If > Catch ex As Exception > MessageBox.Show(ex.ToString, "Error", > MessageBoxButtons.OK, MessageBoxIcon.Error) > End Try > Next > > Else > MessageBox.Show("Source or target doesn't exist.", "Error", > MessageBoxButtons.OK, MessageBoxIcon.Error) > End If > End Sub > > -- > Programming today is a race between software engineers striving to build > bigger and better idiot-proof programs, and the Universe trying to produce > bigger and better idiots. So far, the Universe is winning. (Rich Cook) > > "Dennis" <Den***@discussions.microsoft.com> schreef in bericht > news:D4679DD8-C054-4696-9BF7-6BF64C4E906F@microsoft.com... > > Why can't you write a simple routine to copy all the files in your source > > directory to your new directory using the copy method of the file class. > > -- > > Dennis in Houston > > > > > > "samoore33" wrote: > > > > > Thanks a lot Izzy, it is working now. > > > > > > Izzy wrote: > > > > Try this: > > > > > > > > XCOPY C:\Pictures "C:\Documents and Settings\smoore\My > > > > Documents\Pictures" /e /c /i /h /k > > > > > > > > This issus is you didn't enclose the path with spaces in quatation > > > > marks. Look at the link I sent too see what the switches mean. > > > > > > > > Izzy > > > > > > > > > > > > samoore33 wrote: > > > > > I am trying to use the XCOPY command in a batch file. This is what I > am > > > > > trying to do. > > > > > > > > > > @echo off > > > > > > > > > > XCOPY C:\Pictures C:\Documents and Settings\smoore\My > > > > > Documents\Pictures > > > > > > > > > > Pause > > > > > > > > > > When I run this I get Invalid number of parameters? > > > > > > > > > > Not sure what I am doing wrong here, please advise. > > > > > > > > > > Scott > > > > > > > > > > Izzy wrote: > > > > > > Scott, > > > > > > > > > > > > You may or may not like this method, but I thought I'd post it > anyway. > > > > > > > > > > > > You could use xcopy in a .bat file to copy the directory from one > > > > > > location to another. Using different switches for xcopy you can > include > > > > > > hidden files, subdirectories, ignore errors, automatically create > > > > > > subdirectories, turn message prompts off and a bunch of other > options. > > > > > > Here is a complete list of switch options for xcopy: > > > > > > > > > > > > http://www.computerhope.com/xcopyhlp.htm > > > > > > > > > > > > You could call this .bat file using > > > > > > System.Diagnostics.Process.Start([Path To .bat File]) > > > > > > I think you should be able to hide the command window from showing > up. > > > > > > > > > > > > By starting a new process you would be able to tell when the > process > > > > > > finishes. Additionally you could modify the .bat file in the > future so > > > > > > code changes would not be necessary. > > > > > > > > > > > > Just a thought, > > > > > > Izzy > > > > > > > > > > > > samoore33 wrote: > > > > > > > I found a real nice article on how to copy a directory on MSDN. > The > > > > > > > only problem is that I can not figure out how to get the > namespace > > > > > > > Microsoft.VisualBasic.MyServices. I wanted to know if anyone > else has > > > > > > > had experience with this, or knows of a different way to copy a > > > > > > > directory using VB. > > > > > > > > > > > > > > I found ways to copy files, but not having a lot of luck with > finding a > > > > > > > way to copy a directory other then this information I am finding > on > > > > > > > MSDN. > > > > > > > > > > > > > > Thanks > > > > > > > > > > > > > > Scott Moore > > > > > >
Windows Service, timer doesn't tick
Any examples of this floating around? Difference between CDec and CDbl ComboBox Help with some research multi line list box Run Adobe Acrobat from within VB.Net app ComboBox-binding an ein gefiltertes Dataset.Table-Object VB.NET AND 3D How to close the parent and all child forms together at once when click on parent window's close but |
|||||||||||||||||||||||