473,545 Members | 1,618 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

File copy in asp

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("c ontemplate")
strContractId = request.form("c ontractId")

strfileName = strTemplateName
strDestFileName = strContractId & strTemplateName

strOrgPath = "c:\InetPub\www root\mypro\temp lates\" & strFilename
strDestinationP ath = "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.

strDestinationP ath = "c:\" & "metext.txt "

' Example code 1
Dim objFSO
Set objFSO = CreateObject("S cripting.FileSy stemObject")
objFSO.CopyFile strOrgPath, strDestinationP ath

' Example code 2
set fs=Server.Creat eObject("Script ing.FileSystemO bject")
set f=fs.GetFile(st rOrgPath )
f.Copy strDestinationP ath ,false
set f=nothing
set fs=nothing
%>
Aug 22 '05 #1
2 16180
JP SIngh wrote on 22 aug 2005 in
microsoft.publi c.inetserver.as p.general:
strOrgPath = "c:\InetPub\www root\mypro\temp lates\" & strFilename
strDestinationP ath = "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
Perhaps try changing this:
strDestinationP ath = "c:\" & "metext.txt "

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

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

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("c ontemplate")
strContractId = request.form("c ontractId")

strfileName = strTemplateName
strDestFileName = strContractId & strTemplateName

strOrgPath = "c:\InetPub\www root\mypro\temp lates\" & strFilename
strDestinationP ath = "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.

strDestinationP ath = "c:\" & "metext.txt "

' Example code 1
Dim objFSO
Set objFSO = CreateObject("S cripting.FileSy stemObject")
objFSO.CopyFile strOrgPath, strDestinationP ath

' Example code 2
set fs=Server.Creat eObject("Script ing.FileSystemO bject")
set f=fs.GetFile(st rOrgPath )
f.Copy strDestinationP ath ,false
set f=nothing
set fs=nothing
%>


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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4313
by: Tony George | last post by:
Hi, I'm having a problem using the Copy module on a ClearCase view that's been set as "readonly" (i.e. ct chview -readonly <view tag>). I want to copy a file out of this view and put it in another directory that's outside of ClearCase. The strange thing is that the copy command actually copies correctly. The problem is that it returns a...
0
2577
by: Tess | last post by:
Hi, Long time reader, first time poster... Any help is appreciated. I have a few questions regarding Winform controls embedded within an html page. For more info please see the appendix. Now, for the questions. 1. A button on my control executes the System.IO.Directory.GetDirectories funtion (the scanned directory resides on the hosting...
0
2081
by: SeanR | last post by:
I have a function to copare two files. It will first copy the original file form a different server to a local temp path and then compare that version to a version that has been restored form tape. Once the compare is complete the file that was copied to a temp location needs to be deleted. I am using the method file.copy(sourcePath,...
4
1464
by: Pino | last post by:
What is the fastest way to copy a file from a device to a different destination? I know there is a difference between File.Copy and the FileCopy API. Thanks, Pino.
4
3460
by: adnan boz | last post by:
Hi All, Does somebody know why File.Copy function is 10 times slower than standard windows drag and drop copy between folders, when I copy files over the network? Actually, I need to copy files from one computer to another over a 1GBit ethernet network as fast as I can. Although windows copy works at %40 performance, File.Copy could not go...
2
5497
by: Pete Davis | last post by:
I'm getting an exception when trying to copy a file. I basically do a File.Copy(source, dest, false); source is the source full path and filename. dest is the destination full path and filename. The file actually appears to copy just fine. The problem is it throws an IOException with the message:
2
3756
by: Stephen Witter | last post by:
I had previously posted this on the security ng, but haven't had a hit so I was wondering if someone here would be willing to take a stab. I am trying to copy a file to a network drive. I can do it on the web server but not from a client. Here is the code: Dim impersonationContext As System.Security.Principal.WindowsImpersonationContext...
8
2913
by: luis molina Micasoft | last post by:
it seems that when i do file.copy the svchost.exe is hanged, i mean if i make 40 threads of file.copy , 40 copys of files at same time the system is going down and stop responding, this is when i'm working with cifs (shares). there is another solution to copy files than file.copy in .net?
1
4257
by: =?Utf-8?B?UmFkZW5rb19aZWM=?= | last post by:
I am using standard File.Copy(source,dest,true) method in C# and I have problem with copying large number of files. Here is my code: foreach (FileInfo file in files) { File.Copy(file.FullName,destPath+ "\\" + file.Name, true); } This code copies only 5 or 10 files but in "files" collection there is 60 files.
3
5121
by: =?Utf-8?B?R2FuZXNoYQ==?= | last post by:
Hi I would like to use File.Copy with UNC paths. I have seen this problem reported by others as well. Can i use File.Copy with UNC paths. ie., i would like to copy a file from one of the folder to a shared folder. eg., File.Copy(srcPath, "\\machinename\\folder) This is giving an error "Could not find part of the path...
0
7459
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7393
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7803
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7411
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5965
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5322
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3444
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3439
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1871
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.