p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Basics (http://p2p.wrox.com/forumdisplay.php?f=61)
-   -   File Already exists Error (http://p2p.wrox.com/showthread.php?t=54113)

srsandhu February 15th, 2007 01:14 PM

File Already exists Error
 
Hello

Does anybody know how to fix
Microsoft VBScript runtime error '800a003a'

File already exists

/messaging/sendmessageprocess.asp, line 12




dparsons February 15th, 2007 01:27 PM

Thanks for moving to the correct forum but you are not being any more clear then in your Original Post (http://p2p.wrox.com/topic.asp?TOPIC_ID=56301). That error literally means that a file you are trying to create already exists, my guess is that you have not told the FSO object that it can overwrite the file if it already exists.




================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html

srsandhu February 15th, 2007 01:50 PM

Thanks dparsons, i will try o give FSO the permission to overwrite the file.
Thanks


srsandhu February 20th, 2007 04:31 PM

Here is the coding I am using for replying to an email(Replying to an email is a service in our website) When I try to reply to an email It Gives me
Microsoft VBScript runtime error '800a003a'

File already exists

/messaging/sendmessageprocess.asp, line 12


CODE


<%
SID=Request("SID")
UID=Request("UID")
UserID=Request("UserID")

Dim UserFolder
Dim MailFolder
SET UserFolder=Server.CreateObject("Scripting.FileSyst emObject")
SET MailFolder=Server.CreateObject("Scripting.FileSyst emObject")
IF NOT UserFolder.FolderExists("C:\Program Files\Ensim\WEBppliance\SiteData\Domains\userphoto s.primallink.com\ROOT\Inetpub\wwwroot/" & UserID & "") THEN
UserFolder.CreateFolder("C:\Program Files\Ensim\WEBppliance\SiteData\Domains\userphoto s.primallink.com\ROOT\Inetpub\wwwroot/" & UserID & "")
    IF NOT MailFolder.FolderExists("C:\Program Files\Ensim\WEBppliance\SiteData\Domains\userphoto s.primallink.com\ROOT\Inetpub\wwwroot/" & UserID & "/mail/") THEN
    MailFolder.CreateFolder("C:\Program Files\Ensim\WEBppliance\SiteData\Domains\userphoto s.primallink.com\ROOT\Inetpub\wwwroot/" & UserID & "/mail/")
    END IF
END IF
    IF NOT MailFolder.FolderExists("C:\Program Files\Ensim\WEBppliance\SiteData\Domains\userphoto s.primallink.com\ROOT\Inetpub\wwwroot/" & UserID & "/mail/") THEN
    MailFolder.CreateFolder("C:\Program Files\Ensim\WEBppliance\SiteData\Domains\userphoto s.primallink.com\ROOT\Inetpub\wwwroot/" & UserID & "/mail/")
    END IF
SET UserFolder=NOTHING
SET MailFolder=NOTHING

Set Upload = Server.CreateObject("Persits.Upload")
Upload.Save "C:\Program Files\Ensim\WEBppliance\SiteData\Domains\userphoto s.primallink.com\ROOT\Inetpub\wwwroot/" & UserID & "/mail/"
path = "C:\Program Files\Ensim\WEBppliance\SiteData\Domains\userphoto s.primallink.com\ROOT\Inetpub\wwwroot/" & UserID & "/mail/"

Sender=Upload.Form("Sender")
Recipient=Upload.Form("Recipient")

Title=Upload.Form("Title") 'needed to block patterns
Message=Upload.Form("Message") 'needed to block patterns

Response.Cookies("TitleCookie")=Title
Response.Cookies("MessageCookie")=Message

Attach=Upload.Form("Attach") 'detect if photo attachment required - if yes(1) AttachPhoto() else skip

IF Attach=1 THEN
    AttachPhoto()
ELSE
    SendMail()
END IF
'================================================= =======
'------------------ ATTACH PHOTO -----------------------
'================================================= =======
FUNCTION AttachPhoto()
Set File = Upload.Files("ThePhoto")
Hash = File.MD5Hash

'Declare the Photo Name
Set FSO=Server.CreateObject("scripting.filesystemobjec t")
Set FS=FSO.GetFile (path & "/" & File.ExtractFileName)
PhotoName=FS.name

'Begin Individual File Checks
'Size checking
Dim DelPhoto

IF File.Size > 50000 THEN
    SET DelPhoto = Server.CreateObject("Scripting.FileSystemObject")
    IF DelPhoto.FileExists("C:\Program Files\Ensim\WEBppliance\SiteData\Domains\userphoto s.primallink.com\ROOT\Inetpub\wwwroot/" & UserID & "/mail/" & PhotoName) THEN
    DelPhoto.DeleteFile("C:\Program Files\Ensim\WEBppliance\SiteData\Domains\userphoto s.primallink.com\ROOT\Inetpub\wwwroot/" & UserID & "/mail/" & PhotoName)
    END IF
    SET DelPhoto=NOTHING
    AttachError=AttachError & "&AttachError=1"
    Response.Redirect "sendmessage.asp?SID=" & SID & "&UID=" & UID & "&UserID=" & UserID & "&PhotoReport=1#Photo"
END IF

IF File.ImageWidth > 500 THEN
    SET DelPhoto = Server.CreateObject("Scripting.FileSystemObject")
    IF DelPhoto.FileExists("C:\Program Files\Ensim\WEBppliance\SiteData\Domains\userphoto s.primallink.com\ROOT\Inetpub\wwwroot/" & UserID & "/mail/" & PhotoName) THEN
    DelPhoto.DeleteFile("C:\Program Files\Ensim\WEBppliance\SiteData\Domains\userphoto s.primallink.com\ROOT\Inetpub\wwwroot/" & UserID & "/mail/" & PhotoName)
    END IF
    SET DelPhoto=NOTHING
    AttachError=AttachError & "&AttachError=2"
    Response.Redirect "sendmessage.asp?SID=" & SID & "&UID=" & UID & "&UserID=" & UserID & "&PhotoReport=2#Photo"
END IF

IF File.ImageHeight > 500 THEN
    SET DelPhoto = Server.CreateObject("Scripting.FileSystemObject")
    IF DelPhoto.FileExists("C:\Program Files\Ensim\WEBppliance\SiteData\Domains\userphoto s.primallink.com\ROOT\Inetpub\wwwroot/" & UserID & "/mail/" & PhotoName) THEN
    DelPhoto.DeleteFile("C:\Program Files\Ensim\WEBppliance\SiteData\Domains\userphoto s.primallink.com\ROOT\Inetpub\wwwroot/" & UserID & "/mail/" & PhotoName)
    END IF
    SET DelPhoto=NOTHING
    AttachError=AttachError & "&AttachError=3"
    Response.Redirect "sendmessage.asp?SID=" & SID & "&UID=" & UID & "&UserID=" & UserID & "&PhotoReport=3#Photo"
END IF

IF File.ImageType = "UNKNOWN" THEN
    SET DelPhoto = Server.CreateObject("Scripting.FileSystemObject")
    IF DelPhoto.FileExists("C:\Program Files\Ensim\WEBppliance\SiteData\Domains\userphoto s.primallink.com\ROOT\Inetpub\wwwroot/" & UserID & "/mail/" & PhotoName) THEN
    DelPhoto.DeleteFile("C:\Program Files\Ensim\WEBppliance\SiteData\Domains\userphoto s.primallink.com\ROOT\Inetpub\wwwroot/" & UserID & "/mail/" & PhotoName)
    END IF
    SET DelPhoto=NOTHING
    AttachError=AttachError & "&AttachError=4"
    Response.Redirect "sendmessage.asp?SID=" & SID & "&UID=" & UID & "&UserID=" & UserID & "&PhotoReport=4#Photo"
END IF

IF AttachError="" OR AttachError=NULL THEN
    'Ok to attach the photo
    SET Conn = Server.CreateObject("ADODB.Connection")
    Conn.open "DSN=xxx; uid=xxx; pwd=xxx"
    msSQL = "Execute sproc_MessagingPhotos_Add '" & UID & "','" & UserID & "','" & PhotoName & "','" & File.ImageWidth & "','" & File.ImageHeight & "'"
    SET ORs = Conn.EXECUTE(msSQL)

    SET ORs = NOTHING
    Conn.close

    'Ok to process the SendMail() function
    SendMail()
END IF

END FUNCTION
'================================================= =======
'------------------- SEND LETTER -----------------------
'================================================= =======
FUNCTION SendMail()
    Dim rx
    SET rx = New RegExp
    rx.Pattern = "\w{35}"
    IF rx.Test(Title) THEN
        Response.Redirect "sendmessage.asp?SID=" & SID & "&UID=" & UID & "&UserID=" & UserID & "&Report=1"
    ELSEIF rx.Test(Message) THEN
        Response.Redirect "sendmessage.asp?SID=" & SID & "&UID=" & UID & "&UserID=" & UserID & "&Report=1"
    ELSE

    Title = Replace(Upload.Form("Title"), chr(34), "&quot;") 'Double Quote Check "
    Title = Replace(Upload.Form("Title"), "'", "#39;") 'Single Quote Check '
    Title = Replace(Upload.Form("Title"), chr(13), "<br>") 'Carriage Return
    Title = Replace(Title, "#", "#35;") '# date marker
    Title = Replace(Upload.Form("Title"), "'", "#39;") 'Single Quote Check '

    Message = Replace(Upload.Form("Message"), chr(34), "&quot;") 'Double Quote Check "
    Message = Replace(Upload.Form("Message"), "'", "#39;") 'Single Quote Check '
    Message = Replace(Upload.Form("Message"), "#", "#35;") '# date marker
    Message = Replace(Upload.Form("Message"), "'", "#39;") 'Single Quote Check '

    Set conn = Server.CreateObject("ADODB.Connection")
    conn.open "DSN=xxx;uid=xxx; pwd=xxx"
    msSQL = "Execute sproc_MessagingSendingMessage '" & SID & "','" & Recipient & "','" & Sender & "','" & Title & "','" & Message & "'"
    Set ORs = Conn.Execute(msSQL)

    Set ORs = Nothing
    conn.close

    Response.Redirect "sendmessage_show.asp?SID=" & SID & "&UID=" & UID
    END IF
END FUNCTION
%>



dparsons February 20th, 2007 04:34 PM

Show me everything up to line 12.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html

Discussion:
http://p2p.wrox.com/topic.asp?TOPIC_ID=56429

srsandhu February 20th, 2007 05:49 PM


Here is everything upto line 12
<%
SID=Request("SID")
UID=Request("UID")
UserID=Request("UserID")

Dim UserFolder
Dim MailFolder
SET UserFolder=Server.CreateObject("Scripting.FileSyst emObject")
SET MailFolder=Server.CreateObject("Scripting.FileSyst emObject")
IF NOT UserFolder.FolderExists("C:\Program Files\Ensim\WEBppliance\SiteData\Domains\userphoto s.primallink.com\ROOT\Inetpub\wwwroot/" & UserID & "") THEN


srsandhu February 23rd, 2007 09:53 AM

Does anybody know any solution to this problem?
Thanks in advance


solos February 23rd, 2007 04:21 PM

instead of:
Code:

IF NOT UserFolder.FolderExists("C:\Program Files\Ensim\WEBppliance\SiteData\Domains\userphotos.primallink.com\ROOT\Inetpub\wwwroot/" & UserID & "") THEN
UserFolder.CreateFolder("C:\Program Files\Ensim\WEBppliance\SiteData\Domains\userphotos.primallink.com\ROOT\Inetpub\wwwroot/" & UserID & "")

try something along these lines:
Code:

if UserFolder.FolderExists("C:\Program Files\Ensim\WEBppliance\SiteData\Domains\userphotos.primallink.com\ROOT\Inetpub\wwwroot/" & UserID & "")=false then
UserFolder.CreateFolder("C:\Program Files\Ensim\WEBppliance\SiteData\Domains\userphotos.primallink.com\ROOT\Inetpub\wwwroot/" & UserID & "")
else
'do nothing
end if







All times are GMT -4. The time now is 03:30 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.