File Object Permission

I'm making an admin screen so that the administrator can change the content of file remotely anywhere.

But, I got the following error

D:\WWW HOSTING\ABC\Mullin\test\adrot.txt

Microsoft VBScript runtime error '800a0046'

Permission denied


Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
        adrotfile = (Server.MapPath("\Mullin\test") + "\adrot.txt")
        
        Response.Write adrotfile & "<br>" & "<br>"
        ' For Appending
        Set AppendStream = FileObject.OpenTextFile(adrotfile, ForAppending, False, 0)
        ' For Reading
        Set InStream = FileObject.OpenTextFile(adrotfile, ForReading, False, 0)
        ' For Overwriting
        
              FileObject.DeleteFile(adrotfile)
              Set OutStream = FileObject.CreateTextFile(adrotfile, True, False)
        End If

The error states that no permission to run
FileObject.DeleteFile and I got another error that I have no permission to run
FileObject.CreateTextFile(adrotfile, True, False)

However, I can append content to the text file, but not create or overwrite.

What can I do?

I've already set the permission to Full Control to EveryOne

Thanks!


mscprojAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Yury_DelendikCommented:
You must close file before deleting.

....
   Set AppendStream = Nothing
   Set InStream = Nothing

   FileObject.DeleteFile(adrotfile)
....
0
mscprojAuthor Commented:
As I told you on my question, even I remark the Delete statement, still "Permission Denied", it seems that I can't CreateTextFile

My latest code is
<%      
      Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
        adrotfile = (Server.MapPath("\abc\test") + "\adrot.txt")
        'adrotfile = "http://www.intern.com/abc/test/adrot.txt"
        Response.Write adrotfile & "<br>" & "<br>"
        
        ' For Appending
        Set AppendStream = FileObject.OpenTextFile(adrotfile, ForAppending, False, 0)
        ' For Reading
        Set InStream = FileObject.OpenTextFile(adrotfile, ForReading, False, 0)
        ' For Overwriting
        If Request("Action") = "Remove" Or Request("Action") = "Edit" Then
              'FileObject.DeleteFile(adrotfile)
              Set OutStream = FileObject.CreateTextFile(adrotfile, True, False)
        End If

The error statement is pointing to
Set OutStream = FileObject.CreateTextFile(adrotfile, True, False)

Error Message

Microsoft VBScript runtime error '800a0046'

Permission denied
0
mscprojAuthor Commented:
Sorry, your answer gives me some insights and I solve it at last.

Therefore, please post your answer again for the points!

Cheers!
0
Yury_DelendikCommented:
You must close file before deleting.

.....
   Set AppendStream = Nothing
   Set InStream = Nothing

   FileObject.DeleteFile(adrotfile)
.....
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.