kmurphy7
asked on
Permission Denied.
Thank You in advance
I have a page that works just fine for me. Nobody else can get to it. They get Permission Denied. I have the exact same right on the folder the file is being written to. The line that it is crashing on is:
set file = fso.CreateTextFile(thePath , true)
Does CreateTextFile use some dll or something to that effect. My nt account is set up the exact same and I have the same rights(change) on the folder where I am trying to create the text file.
Thank You,
Kent
I have a page that works just fine for me. Nobody else can get to it. They get Permission Denied. I have the exact same right on the folder the file is being written to. The line that it is crashing on is:
set file = fso.CreateTextFile(thePath
Does CreateTextFile use some dll or something to that effect. My nt account is set up the exact same and I have the same rights(change) on the folder where I am trying to create the text file.
Thank You,
Kent
Make sure the IUSER_ has Write permission on the folder the text file is writing to.
If
>>I have the exact same right on the folder the file is being written to
then my first guess would be thePath var with CreateTextFile.
Check the value of thePath, whetehr they have permission on to that folder.
thepath is in correct format etc.
Do a Response.write thePath and see the value
>>I have the exact same right on the folder the file is being written to
then my first guess would be thePath var with CreateTextFile.
Check the value of thePath, whetehr they have permission on to that folder.
thepath is in correct format etc.
Do a Response.write thePath and see the value
And of course, from MSDN;
Dim fso, MyFile
Set fso = CreateObject("Scripting.Fi leSystemOb ject")
Set MyFile = fso.CreateTextFile("c:\tes tfile.txt" , True)
MyFile.WriteLine("This is a test.")
MyFile.Close
Dim fso, MyFile
Set fso = CreateObject("Scripting.Fi
Set MyFile = fso.CreateTextFile("c:\tes
MyFile.WriteLine("This is a test.")
MyFile.Close
ASKER
Sorry, I forgot to note that Basic is turned on and Anonymous is turned off. Here is the full code.
Dim IniFileDictionary
set IniFileDictionary = CreateObject("Scripting.Di ctionary")
Sub IniFileLoad(ByVal FilSpc)
Dim PhyPth
Dim FilSys
Dim IniFil
Dim StrBuf
Dim HdrBuf
Dim StrPtr
Dim AltBuf
IniFileDictionary.RemoveAl l
FilSpc = lcase(FilSpc)
if left(FilSpc, 1) = "p" then
'Physical path
PhyPth = mid(FilSpc, instr(FilSpc, "=") + 1)
else
'Virtual path
PhyPth = Server.MapPath(mid(FilSpc, instr(FilSpc, "=") + 1))
end if
set FilSys = CreateObject("Scripting.Fi leSystemOb ject")
set IniFil = FilSys.OpenTextFile(PhyPth , 1)
do while not IniFil.AtEndOfStream
StrBuf = IniFil.ReadLine
if StrBuf <> "" then
'There is data on this line
if left(StrBuf, 1) <> ";" then
'It's not a comment
if left(StrBuf, 1) = "[" then
'It's a section header
HdrBuf = mid(StrBuf, 2, len(StrBuf) - 2)
else
'It's a value
StrPtr = instr(StrBuf, "=")
AltBuf = lcase(HdrBuf & "|" & left(StrBuf, StrPtr - 1))
do while IniFileDictionary.Exists(A ltBuf)
AltBuf = AltBuf & "_"
loop
IniFileDictionary.Add AltBuf, mid(StrBuf, StrPtr + 1)
end if
end if
end if
loop
IniFil.Close
set IniFil = nothing
set FilSys = nothing
End Sub
Function IniFileValue(ByVal ValSpc)
dim ifarray
Dim StrPtr
Dim StrBuf
StrPtr = instr(ValSpc, "|")
ValSpc = lcase(ValSpc)
if StrPtr = 0 then
'They want the whole section
StrBuf = ""
StrPtr = len(ValSpc) + 1
ValSpc = ValSpc + "|"
ifarray = IniFileDictionary.Keys
for i = 0 to IniFileDictionary.Count - 1
if left(ifarray(i), StrPtr) = ValSpc then
'This is from the section
if StrBuf <> "" then
StrBuf = StrBuf & "~"
end if
StrBuf = StrBuf & ifarray(i) & "=" & IniFileDictionary(ifarray( i))
end if
next
else
'They want a specific value
StrBuf = IniFileDictionary(ValSpc)
end if
IniFileValue = StrBuf
End Function
call IniFileLoad("virtual=Commo n/expenseR eport.ini" )
thePath = IniFileValue("SaveErs|Path ") & "include.txt"
set fso = CreateObject("Scripting.Fi leSystemOb ject")
set file = fso.CreateTextFile(thePath , true)
file.WriteLine("Created on " & now)
file.Close
Thanks Again,
Kent
Dim IniFileDictionary
set IniFileDictionary = CreateObject("Scripting.Di
Sub IniFileLoad(ByVal FilSpc)
Dim PhyPth
Dim FilSys
Dim IniFil
Dim StrBuf
Dim HdrBuf
Dim StrPtr
Dim AltBuf
IniFileDictionary.RemoveAl
FilSpc = lcase(FilSpc)
if left(FilSpc, 1) = "p" then
'Physical path
PhyPth = mid(FilSpc, instr(FilSpc, "=") + 1)
else
'Virtual path
PhyPth = Server.MapPath(mid(FilSpc,
end if
set FilSys = CreateObject("Scripting.Fi
set IniFil = FilSys.OpenTextFile(PhyPth
do while not IniFil.AtEndOfStream
StrBuf = IniFil.ReadLine
if StrBuf <> "" then
'There is data on this line
if left(StrBuf, 1) <> ";" then
'It's not a comment
if left(StrBuf, 1) = "[" then
'It's a section header
HdrBuf = mid(StrBuf, 2, len(StrBuf) - 2)
else
'It's a value
StrPtr = instr(StrBuf, "=")
AltBuf = lcase(HdrBuf & "|" & left(StrBuf, StrPtr - 1))
do while IniFileDictionary.Exists(A
AltBuf = AltBuf & "_"
loop
IniFileDictionary.Add AltBuf, mid(StrBuf, StrPtr + 1)
end if
end if
end if
loop
IniFil.Close
set IniFil = nothing
set FilSys = nothing
End Sub
Function IniFileValue(ByVal ValSpc)
dim ifarray
Dim StrPtr
Dim StrBuf
StrPtr = instr(ValSpc, "|")
ValSpc = lcase(ValSpc)
if StrPtr = 0 then
'They want the whole section
StrBuf = ""
StrPtr = len(ValSpc) + 1
ValSpc = ValSpc + "|"
ifarray = IniFileDictionary.Keys
for i = 0 to IniFileDictionary.Count - 1
if left(ifarray(i), StrPtr) = ValSpc then
'This is from the section
if StrBuf <> "" then
StrBuf = StrBuf & "~"
end if
StrBuf = StrBuf & ifarray(i) & "=" & IniFileDictionary(ifarray(
end if
next
else
'They want a specific value
StrBuf = IniFileDictionary(ValSpc)
end if
IniFileValue = StrBuf
End Function
call IniFileLoad("virtual=Commo
thePath = IniFileValue("SaveErs|Path
set fso = CreateObject("Scripting.Fi
set file = fso.CreateTextFile(thePath
file.WriteLine("Created on " & now)
file.Close
Thanks Again,
Kent
What does thePath returns ? Did you check that ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Second of all, with Basic authentication, the logged in user must have Read/Write on the directory that the FSO is attempting to write to.
permissions indeed..
I had the same problem today. I resolved it by making sure the path was not a network path. Example instead of "\\server\foldername\file" , I put "d:\foldername\file".
lmred
lmred
As I said...
Set MyFile = fso.CreateTextFile("c:\tes tfile.txt" , True)
Set MyFile = fso.CreateTextFile("c:\tes
It appears this question has been abandoned.
I will leave a recommendation in the Cleanup topic area that this question will be:
- Points to mgfranz -
Please leave any comments here within the next seven days.
DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Wakie,
EE Cleanup Volunteer.
I will leave a recommendation in the Cleanup topic area that this question will be:
- Points to mgfranz -
Please leave any comments here within the next seven days.
DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Wakie,
EE Cleanup Volunteer.