FSO.CopyFolder works differently than Shell.Application.Namespace.CopyHere 
Author Message
 FSO.CopyFolder works differently than Shell.Application.Namespace.CopyHere

I want to use the following code to copy the contents of a folder to another
location with a progoress bar...

Sub ShellCopyFolder(folsrc, foltarget)
 ' Displays copy dialog copying from
 ' folsrc to foltarget
 ' foltarget MUST EXIST
 Const FOF_CREATEPROGRESSDLG = &H0&
 Set SA = CreateObject("Shell.Application")
 Set Fol = SA.NameSpace(foltarget)
 Fol.CopyHere folsrc, FOF_CREATEPROGRESSDLG
End Sub

However, this works differently than the FSO.CopyFolder i used to use.
CopyHere is copying the folder *itelf* to the destination rather than the
contents of the folder as CopyFolder does. Ive read that CopyHere can work
with folder items collections rather than path strings, but it would seem
like a huge hassle to have to build the src and destination collections when
i simply want to copy the folder contents. Ive looked up the options flags
of CopyHere to see if anything would help, but FILESONLY is the closest i
could find and it doesnt help.



Wed, 22 Dec 2004 03:37:58 GMT  
 FSO.CopyFolder works differently than Shell.Application.Namespace.CopyHere
Why not to use a wildcard to specify folder content?
Like folsrc = "c:\temp\*.*"
This will copy the *content* of the folder "temp" to the destination.

Regards,
--
Gurgen Alaverdian
http://www.gurgensvbstuff.com

Quote:
> I want to use the following code to copy the contents of a folder to
another
> location with a progoress bar...

> Sub ShellCopyFolder(folsrc, foltarget)
>  ' Displays copy dialog copying from
>  ' folsrc to foltarget
>  ' foltarget MUST EXIST
>  Const FOF_CREATEPROGRESSDLG = &H0&
>  Set SA = CreateObject("Shell.Application")
>  Set Fol = SA.NameSpace(foltarget)
>  Fol.CopyHere folsrc, FOF_CREATEPROGRESSDLG
> End Sub

> However, this works differently than the FSO.CopyFolder i used to use.
> CopyHere is copying the folder *itelf* to the destination rather than the
> contents of the folder as CopyFolder does. Ive read that CopyHere can work
> with folder items collections rather than path strings, but it would seem
> like a huge hassle to have to build the src and destination collections
when
> i simply want to copy the folder contents. Ive looked up the options flags
> of CopyHere to see if anything would help, but FILESONLY is the closest i
> could find and it doesnt help.



Wed, 22 Dec 2004 12:34:11 GMT  
 FSO.CopyFolder works differently than Shell.Application.Namespace.CopyHere
Yes, i tried that but i kept getting an error. It didnt seem to like the
wildcard path.


Quote:
> Why not to use a wildcard to specify folder content?
> Like folsrc = "c:\temp\*.*"
> This will copy the *content* of the folder "temp" to the destination.

> Regards,
> --
> Gurgen Alaverdian
> http://www.gurgensvbstuff.com


> > I want to use the following code to copy the contents of a folder to
> another
> > location with a progoress bar...

> > Sub ShellCopyFolder(folsrc, foltarget)
> >  ' Displays copy dialog copying from
> >  ' folsrc to foltarget
> >  ' foltarget MUST EXIST
> >  Const FOF_CREATEPROGRESSDLG = &H0&
> >  Set SA = CreateObject("Shell.Application")
> >  Set Fol = SA.NameSpace(foltarget)
> >  Fol.CopyHere folsrc, FOF_CREATEPROGRESSDLG
> > End Sub

> > However, this works differently than the FSO.CopyFolder i used to use.
> > CopyHere is copying the folder *itelf* to the destination rather than
the
> > contents of the folder as CopyFolder does. Ive read that CopyHere can
work
> > with folder items collections rather than path strings, but it would
seem
> > like a huge hassle to have to build the src and destination collections
> when
> > i simply want to copy the folder contents. Ive looked up the options
flags
> > of CopyHere to see if anything would help, but FILESONLY is the closest
i
> > could find and it doesnt help.



Fri, 24 Dec 2004 22:40:53 GMT  
 FSO.CopyFolder works differently than Shell.Application.Namespace.CopyHere

Quote:

> Yes, i tried that but i kept getting an error. It didnt seem to like
> the wildcard path.

Check the documentation...

CopyHere
http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/refere...

Look at the description for the vOptions arguments, in particular the flag value of 128...

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--



Sat, 25 Dec 2004 01:01:18 GMT  
 FSO.CopyFolder works differently than Shell.Application.Namespace.CopyHere
Yep, im aware of that option, but that option will copy files only and not
folders.



Quote:

> Yes, i tried that but i kept getting an error. It didnt seem to like
> the wildcard path.

Check the documentation...

CopyHere
http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/refere...
ects/folder/copyhere.asp

Look at the description for the vOptions arguments, in particular the flag
value of 128...

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--



Sat, 25 Dec 2004 02:11:00 GMT  
 FSO.CopyFolder works differently than Shell.Application.Namespace.CopyHere
If I specify blah/*.* and leave the options 0, i get the error message
"Cannot copy file: cannot read from source file or disk"

If I specify blah/*.* and include the files only switch (128) it copies
nothing. (the blah folder contains only other subfolders, no files)

If i specify blah only, and leave the options 0, it copies the blah folder
itself to the destination, rather than the folders within blah that i am
really wanting to copy.



Quote:

> Yes, i tried that but i kept getting an error. It didnt seem to like
> the wildcard path.

Check the documentation...

CopyHere
http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/refere...
ects/folder/copyhere.asp

Look at the description for the vOptions arguments, in particular the flag
value of 128...

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--



Sat, 25 Dec 2004 02:20:55 GMT  
 FSO.CopyFolder works differently than Shell.Application.Namespace.CopyHere
I'm not sure why you're getting the error. Following works for me:

 Set SA = CreateObject("Shell.Application")
 Set Fol = SA.NameSpace("t:\temp")
 Fol.CopyHere "c:\temp\vbtest\*.*", FOF_CREATEPROGRESSDLG

This copy files and subfolders to the destination.
What error are you getting?
--
Gurgen Alaverdian
http://www.gurgensvbstuff.com

Quote:
> Yep, im aware of that option, but that option will copy files only and not
> folders.




> > Yes, i tried that but i kept getting an error. It didnt seem to like
> > the wildcard path.

> Check the documentation...

> CopyHere

http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/refere...
Quote:
> ects/folder/copyhere.asp

> Look at the description for the vOptions arguments, in particular the flag
> value of 128...

> --
> Michael Harris
> Microsoft.MVP.Scripting
> Seattle WA US
> --



Sat, 25 Dec 2004 02:40:03 GMT  
 FSO.CopyFolder works differently than Shell.Application.Namespace.CopyHere
AHA!

the problem appears to be that CopyHere doesnt like relative paths when
using *.*

Once i used the full path it worked fine.


Quote:
> If I specify blah/*.* and leave the options 0, i get the error message
> "Cannot copy file: cannot read from source file or disk"

> If I specify blah/*.* and include the files only switch (128) it copies
> nothing. (the blah folder contains only other subfolders, no files)

> If i specify blah only, and leave the options 0, it copies the blah folder
> itself to the destination, rather than the folders within blah that i am
> really wanting to copy.




> > Yes, i tried that but i kept getting an error. It didnt seem to like
> > the wildcard path.

> Check the documentation...

> CopyHere

http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/refere...

- Show quoted text -

Quote:
> ects/folder/copyhere.asp

> Look at the description for the vOptions arguments, in particular the flag
> value of 128...

> --
> Michael Harris
> Microsoft.MVP.Scripting
> Seattle WA US
> --



Sat, 25 Dec 2004 02:50:36 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Shell.Application.Count or Shell.Application.Contents.Count

2. Show a window from shell's namespace?

3. How do I get Shell.Application to work in NT 4.0

4. fso.copyfolder vs. folder.copyhere

5. Page.IsClientScriptBlockRegistered not appearing in namespace

6. Can't find the System.Runtime.Serialization.Formatters.Soap namespace

7. http://www.hkfund.simplenet.com/0617ysl/fullist.html-Place For hongkong Copie Cd

8. A Different Count between ListParagraphs.Count and the sum of Lists(index).ListParagraphs.Count

9. BUG: PrintDialog.PrinterSettings.Copies/HP Driver

10. attn: JimSPAMBEGONE@glasgow.freeserve.co.uk

11. a-bisset@aberdeen-harbour.co.uk

12. http://www.mjvn.co.za/rodcom/prbsp.html

 

 
Powered by phpBB® Forum Software