简体   繁体   中英

Getting permission denied error when trying to create file for writing in VBScript

I keep getting permission denied when trying to open the second file here for writing. I know the first file opens fine as I can write it out to the screen and I have set write permissions for users. Is this so simple that I'm being blinded by it???

css_org = server.MapPath("style.css")
css_new = server.MapPath("new_style.css")           
Set fso = CreateObject("Scripting.FileSystemObject")
Const ForReading = 1 
Const ForWriting = 2        
Set objFile1 = fso.OpenTextFile (css_org, ForReading)
Set objFile2 = fso.OpenTextFile (css_new, ForWriting, True)  ' 500 error on this line

您的代码似乎是ASP,因此您需要向运行该代码的用户(通常是运行IIS的服务帐户)授予写权限,而不是登录到Web应用程序的用户。

Have you tried writing to the file outside of code to see if the user context can write to it? It's probably not an issue with your code. You may get a more informative error message if you try to write to it, say, with Notepad. Also, you could try using SysInternals' "Process Explorer" -- their "Find Handle" feature to test that file to see if there is some process locking it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM