Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem Copying files

Status
Not open for further replies.

cdcents

MIS
Aug 8, 2000
16
US
I have tried to copy files using the copy method and the copyfile methods. In either case I get a runtime error saying Permission denied. However the same script successfully creates a file in the destination directory using the OpenTextFile function. This leads me to think that this is not a Permissions problem. Am I missing something?
 
Are you sure that you have read permission for the file that you are trying to copy?
Try opening the file for read and see if you get the same error.
 
Yes I do have read permission. In fact I successfully opened the file for read and was able to read and display the first 150 characters. (That's all I tried) I am able to read and copy/move the file at the OS level (ie. from within Windows and a Command Prompt) I was hoping to develop the filename from some command line parameters. Thinking that it was not being passed correctly I hard coded the filename and the path but still no luck. Thank you for your help. Looking forward to some more. :)
 
How are you performing the copy? I had some fun as well when I first tried to do that with many different servers. It turned out to be all in the syntax.

Try this in a sub
------
Public Sub CopyMe()
dim filesys, Target, Source, ServerName
' change the variables to suit your needs

Target = "\vol1\pubacc\common\apps\client"
Source = "\\NBA_CEN\vol1\pubacc\common\client"
ServerName ="NBA_TEMP"

set filesys = CreateObject("Scripting.FileSystemObject")
' Creates a instance of the filesystem object as filesys
' so it can be used.

'Use filesys.Copyfile to copy a single file.
'Use filesys.CopyFolder to copy folders and all
'their sub contents

filesys.Copyfile Source, "\\" & ServerName & target
'filesys.copyfolder Source, "\\" & ServerName & Target

msgbox "all done"
' Clean up
Set filesys = nothing

End sub

-------

Hope that helps out!




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top