J
JP SIngh
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
%>
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
%>