View Full Version : why not work
bmwmpower
05-03-2003, 11:48 AM
why this code not work in
if the file exists write this file already exists or copy it
response.buffer=true
c=request ("c")
f=request("f")
f2=request("f2")
node= Session("node")
owner=session("temp")
filename = server.mappath(f)
shername = (c)
dim fso , mainfile
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(c)=true then
response.write " This file already exists <a href='directory.asp?d=" & path & " '>Click here</a> to return to file manager<br><br>"
Else
set mainfile =fso.getfile(filename)
mainfile.copy shername & "\" , false
response.Write("it's Okaaaaaaaaaa")
%>
<script>
{ setTimeout("window.close()", 4000)
}
</script>
<%
end if
set mainfile=nothing
set fso=nothing
%>
whammy
05-04-2003, 10:21 PM
Are you getting any errors?
bmwmpower
05-05-2003, 12:02 PM
NO
THE PROBLEM ( when i check if the file exists not work i mean i can copy the file while the file aready exists
whammy
05-05-2003, 03:10 PM
I'm sorry I don't understand.
bmwmpower
05-06-2003, 09:35 AM
ok what i want from this code is
when i copy file to folder if the file already exists tell me ( This file already exists ) and if not copy the file to teh folder
whammy
05-07-2003, 12:45 AM
OK then I don't see any problem with the code, offhand...
I'm not sure why you're assigning so many variables to the same thing, but try this:
shername = c 'this is bad variable naming... what does c mean?
Response.Write("Here is my file: " & c & "<br />" & vbcrlf) 'so you can see the path
dim fso , mainfile
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(c)=true then
response.write " This file already exists <a href='directory.asp?d=" & path & " '>Click here</a> to return to file manager<br><br>"
Else
set mainfile =fso.getfile(filename)
mainfile.copy shername & "\" , false
response.Write("it's Okaaaaaaaaaa")
%>
P.S. That's very confusing code. You're using "c" as your file variable, but when you print out "This file already exists", you're using "path". Perhaps that's part of the problem?
I'd stick to using only the variables you absolutely need, and naming them intelligently... for instance
MyFile
MyFilePath
OriginalFile
or
strMyFile
strMyFilePath
strOriginalFile
But the first thing I'd do is Response.Write the values of the variables you're using (especially at key points in your application!), that's always the way to see what's going wrong.
P.S. Don't forget... why use "shername", "c" and "Path"? Stick to one variable if you can... that may be what has confused you!
bmwmpower
05-07-2003, 11:32 AM
i still have problem in the if statment
if the folder exists or not write "This folder already exists "
The is the code
response.buffer=true
Originalplace =request ("c") ' this is the palce that will copy in it
MyfolderPath= server.mappath(request("f")) ' this is the path of the folder
dim fso , mainfile
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FolderExists(Originalplace)=true then
response.write " This Folder already exists <br>"
else
set mainfile =fso.getfolder(MyfolderPath)
mainfile.copy Originalplace & "\" , false
end if
set mainfile=nothing
set fso=nothing
whammy
05-07-2003, 02:14 PM
So Response.Write OriginalPlace, and make sure it's the path you expect. Other than that I don't see anything wrong with it
arnyinc
05-07-2003, 02:15 PM
I think you need server.mappath on both paths
Originalplace = server.mappath(request ("c"))
MyfolderPath= server.mappath(request("f"))
bmwmpower
05-07-2003, 02:39 PM
i make Response.Write OriginalPlace, and iam sure it's the path i expect
whammy
05-07-2003, 10:18 PM
Did you try Server.MapPath?
What's the path you're getting?
bmwmpower
05-08-2003, 09:37 AM
can u help me in explane this code and how it work i mean the sequence of the code
bmwmpower
05-10-2003, 08:45 AM
why no help
whammy
05-12-2003, 02:11 AM
I'm not really sure what the problem is.
Try these examples, since they work, maybe they would be a good base to start with:
http://www.w3schools.com/asp/asp_ref_filesystem.asp
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.