By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,414 Members | 1,057 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,414 IT Pros & Developers. It's quick & easy.

File copy in asp

P: n/a
Hi All

I want to use ASP to copy a file from one folder to another.

I am using the following code but it gives me a file not found error on the
destination file name. All is want is

1. The user chooses the name of the template from a dropdown.
2. I want to take the template file that the user has choosen
3. Give it a newname ie. strContractId & strTemplateName
4. Copy the file to a new folder with the new name.

<%
strTemplateName = request.form("contemplate")
strContractId = request.form("contractId")

strfileName = strTemplateName
strDestFileName = strContractId & strTemplateName

strOrgPath = "c:\InetPub\wwwroot\mypro\templates\" & strFilename
strDestinationPath = "c:\myusername\" & strDestFileName

' * * * it works if I explicity define the file name like it works but if i
want to create the destination file using the variable like the line above
it fails.
' What is that I am doing wrong.

strDestinationPath = "c:\" & "metext.txt"

' Example code 1
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile strOrgPath, strDestinationPath

' Example code 2
set fs=Server.CreateObject("Scripting.FileSystemObject ")
set f=fs.GetFile(strOrgPath )
f.Copy strDestinationPath ,false
set f=nothing
set fs=nothing
%>
Aug 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
JP SIngh wrote on 22 aug 2005 in
microsoft.public.inetserver.asp.general:
strOrgPath = "c:\InetPub\wwwroot\mypro\templates\" & strFilename
strDestinationPath = "c:\myusername\" & strDestFileName

' * * * it works if I explicity define the file name like it works but
if i want to create the destination file using the variable like the
line above it fails.
' What is that I am doing wrong.


No write rights on the destination directory?

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Aug 22 '05 #2

P: n/a
Perhaps try changing this:
strDestinationPath = "c:\" & "metext.txt"

To be more like this instead (i.e. not stating a filename):
strDestinationPath = "c:\"

And here's a related resource:
CopyFile Method
http://msdn.microsoft.com/library/de.../en-us/script5
6/html/jsmthcopyfile.asp

Best regards,
J. Paul Schmidt, Freelance ASP Web Developer
http://www.Bullschmidt.com
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...

<<
I want to use ASP to copy a file from one folder to another.

I am using the following code but it gives me a file not found error on
the
destination file name. All is want is

1. The user chooses the name of the template from a dropdown.
2. I want to take the template file that the user has choosen
3. Give it a newname ie. strContractId & strTemplateName
4. Copy the file to a new folder with the new name.

<%
strTemplateName = request.form("contemplate")
strContractId = request.form("contractId")

strfileName = strTemplateName
strDestFileName = strContractId & strTemplateName

strOrgPath = "c:\InetPub\wwwroot\mypro\templates\" & strFilename
strDestinationPath = "c:\myusername\" & strDestFileName

' * * * it works if I explicity define the file name like it works but
if i
want to create the destination file using the variable like the line
above
it fails.
' What is that I am doing wrong.

strDestinationPath = "c:\" & "metext.txt"

' Example code 1
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile strOrgPath, strDestinationPath

' Example code 2
set fs=Server.CreateObject("Scripting.FileSystemObject ")
set f=fs.GetFile(strOrgPath )
f.Copy strDestinationPath ,false
set f=nothing
set fs=nothing
%>


*** Sent via Developersdex http://www.developersdex.com ***
Aug 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.