Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
delete from server question
Old 05-02-2006, 03:10 AM delete from server question
Average Talker

Posts: 26
Trades: 0
Hi guys,
I am trying to delete a file from server, but it seems my codes doesn't do any thing and still file is in erver. Could you please help me where I am wrong?

Many thanks,
Elham
------------------- code ----------------------

<%
Set Upload = Server.CreateObject("Persits.Upload")
Count = Upload.Save("C:\Inetpub\wwwroot\stecs-dev\contact\")
Response.Write Count & " file(s) uploaded to C:\Inetpub\wwwroot\stecs-dev\contact\"
Response.write("<hr>")
%>
<%
SUB sendmail( fromWho, toWho, AddAttachment1, Subject, Body )
Dim objCDO
Dim iConf
Dim Flds
Const cdoSendUsingPort = 2
Set objCDO = Server.CreateObject("CDO.Message")
Set iConf = Server.CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
With Flds
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "stecs-exchange.stecs.com"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPconnectiontimeout) = 10
.Update
End With
Set objCDO.Configuration = iConf
objCDO.From = fromWho
objCDO.To = toWho
objCDO.Subject = Subject
objCDO.AddAttachment AddAttachment1
objCDO.TextBody = "CONTACT INFORMATION" & vbCrLf & "____________________" & vbCrLf &_
"Name: " & firstname & vbCrLf & "Company: " &company & vbCrLf &_
"Address: " & Address & vbCrLf & "City: " &city & ", "& state & " " &zip & vbCrLf &_
"Country: " &country & vbCrLf & "phone: " &phone & vbCrLf & "My Message : " & myMessage & vbCrLf & "How did you hear about us? " & Body
objCDO.Send
ConfirmMsg = Response.redirect("thankyou.html")
END SUB
Dim Domainname
Dim MailServer
Dim From
Dim subject1
Domainname = "webdev.stecs.com"
MailServer = Upload.Form("MailServer")
subject1 = "IDS-7934969 - "
fromWho = Upload.Form( "fromWho")
'toWho = Upload.Form( "toWho") + "@stecs.com"
toWho = "resumes@stecs.com"
AddAttachment1= Upload.Files("toAttachment").path
firstname = TRIM( Upload.Form( "Name" ) )
company = TRIM( Upload.Form( "Company" ) )
address = TRIM( Upload.Form( "Address" ) )
city = TRIM( Upload.Form( "City" ) )
state = TRIM( Upload.Form( "State" ) )
zip = TRIM( Upload.Form( "Zip" ) )
country = TRIM( Upload.Form( "Country" ) )
phone = TRIM( Upload.Form( "Phone" ) )
myMessage = TRIM( Upload.Form( "MyMessage" ) )
Subject = TRIM( Upload.Form( "Subject" ) )
Body = TRIM( Upload.Form( "Body") )
send_mail = Upload.Form( "send_mail")
If send_mail <> "" THEN
sendMail fromWho, toWho, AddAttachment1, Subject, Body

'Cleanup
Set ObjCDO = Nothing
Set iConf = Nothing
Set Flds = Nothing
END IF

' DETLETE UNNEEDED FILE AFTER UPLOADING
Dim myFSO
'this line creates an instance of the File Scripting Object named myFSO
SET myFSO = Server.CreateObject("Scripting.FileSystemObject")
'error handling here to make sure that things go smoothly
'if the file does not exist
If myFSO.FileExists(filepath) Then
'then we delete it
myFSO.DeleteFile(AddAttachment1)
response.write("<hr>")
response.write("Temporary file deleted : "&AddAttachment1)
Else
'otherwise we tell the client it does so they don't get a nasty error
Response.Write "THIS FILE DOESN'T EXISTS"
End If
'this line destroys the instance of the File Scripting Object named myFSO
SET myFSO = NOTHING
%>
elham is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-02-2006, 04:11 AM Re: delete from server question
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
deletefile requires an absolute path, check it is getting one and if not use server.mappath() to create one.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-02-2006, 11:04 AM Re: delete from server question
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
You also need to assign something to the Filepath variable. It should be of the form (file path + attachment). It doesn't look like you have.

Response.Write Filepath in the line immediately above
Code:
If myFSO.FileExists(filepath) Then
and see what output you get.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 05-02-2006, 03:21 PM Re: delete from server question
Average Talker

Posts: 26
Trades: 0
Thanks for the responce but one thing I want to know that "AddAttachment1" has a path and file name inside right? if so then why file can not be removed from server, since "AddAttachment1" had path and file name inside to email it to user right?I am puzzled!!!

Elham

BTW I changed this line to:
=====
If myFSO.FileExists(AddAttachment1) Then
=====

Here the code again just delete part:
--------------------------------------------------

' DETLETE UNNEEDED FILE AFTER UPLOADING
Dim myFSO
'this line creates an instance of the File Scripting Object named myFSO
SET myFSO = Server.CreateObject("Scripting.FileSystemObject")
'error handling here to make sure that things go smoothly
'if the file exists
If myFSO.FileExists(AddAttachment1) Then
'then we delete it
myFSO.DeleteFile(AddAttachment1)
response.write("<hr>")
response.write("Temporary file deleted : "&AddAttachment1)
Else
'otherwise we tell the client it does so they don't get a nasty error
Response.Write "THIS FILE DOESN'T EXISTS"
End If
'this line destroys the instance of the File Scripting Object named myFSO
SET myFSO = NOTHING
elham is offline
Reply With Quote
View Public Profile
 
Old 05-02-2006, 03:29 PM Re: delete from server question
Average Talker

Posts: 26
Trades: 0
The reason I am saying "AddAttachment1" should have file and path inside is this line that I used before for sending email...

AddAttachment1= Upload.Files("toAttachment").path

Please advise....
Thanks
Elham
elham is offline
Reply With Quote
View Public Profile
 
Old 05-02-2006, 10:24 PM Re: delete from server question
Average Talker

Posts: 26
Trades: 0
Hi Adam,
Still I a waiting for help but meanwhile as you suggested I used mappath but I guess I am not using it right since still when I upload the file stays in server....

myFSO.DeleteFile(Server.MapPath(AddAttachment1))

Please help
Thanks,
Elham
elham is offline
Reply With Quote
View Public Profile
 
Old 05-03-2006, 04:41 AM Re: delete from server question
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
use (filename,true) to force the delete operation

the file may still be held open
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to delete from server question
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.26516 seconds with 12 queries