writing files/directories using Com objects / with asp
Ok,
i was previously wrong about something.
here's the scoop.
i have a VB com object (code below)
its an example. all it does is create a directory on the computer.
create the .dll
run it in VB, works fine.
run it from asp code, no go.
..
based on some other hints, because the asp runs within the IUSR_machinename
account.
man, i thought this was the one of the big deals with COM... a dll that is
compiled , thus more secure... i thought it would be able to do some stuff
on the server.
are you able to set properties under directories using IIS (or personal web
server) to be able to write to certain directories? when i set up those
permissions, is it the IUSR_machinename account that is affected?
just trying to get the big picture...
thanks
..
sloan
VB / active x dll code
Project Name = TestProj
ClassName = WriteStuff
Option Explicit
Public intErrorNumber As Integer
Public strErrorDescription As String
Private Sub setErrors(lngValue As Long, strValue As String)
intErrorNumber = lngValue
strErrorDescription = strValue
End Sub
Private Sub clearErrors()
intErrorNumber = 0
strErrorDescription = ""
End Sub
Public Function createDirectory(strDirectory As String) As Boolean
clearErrors
On Error GoTo errorhandler:
RmDir strDirectory
MkDir strDirectory
createDirectory = True
Exit Function
errorhandler:
createDirectory = False
Select Case Err.Number
Case 53, 76
Resume Next
Case 75
'i think this is "directory already exists"
intErrorNumber = 75
strErrorDescription = "Error Number 75 raised on 'MKDIR' command for
'" & strDirectory & "'"
Exit Function
Case Else
Call setErrors(Err.Number, "Error creating the directory:" &
strDirectory & vbCrLf & Err.Description)
'Err.Raise intErrorNumber, "", strErrorDescription
End Select
End Function
VB code with reference to above .dll
Option Explicit
Private Sub Command1_Click()
Dim o As TestProj.writestuff
Set o = New TestProj.writestuff
If o.createDirectory("c:\tempa") = True Then
MsgBox "'c:\tempa' was created."
Else
MsgBox o.intErrorNumber & " " & o.strErrorDescription
End If
Set o = Nothing
End Sub
Asp Code
<%
Dim o
Set o = Server.CreateObject("TestProj.WriteStuff")
'Response.write "*" & server.MapPath (".") & "*"
'Response.End
dim strDir
strDir = server.MapPath(".") & "\tempa"
If o.createDirectory(cstr(strDir)) = True Then
response.write "'" & strDir & "' was created."
Else
response.write o.intErrorNumber & "<br>" & o.strErrorDescription
End If
Set o = Nothing
%>