Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Pl review following code-
VB
Function FileProperties( sFileName, sLength, sDateTime, sAttr)
    dim oFS, oFile
    Set oFS = Server.CreateObject("Scripting.FileSystemObject")

    if ( oFS.FileExists( sFileName ) ) then
        set oFile = oFS.GetFile( sFileName )
        sLength = oFile.size
        sDateTime = oFile.DateLastModified
        sAttr = oFile.Attributes

        set oFile = Nothing
        FileProperties = true
    else
        ' might be a folder
        if ( oFS.FolderExists( sFileName ) ) then
            set oFile = oFS.GetFolder( sFileName )

            sLength =  oFile.size 
            sDateTime = oFile.DateLastModified
            sAttr = oFile.Attributes

            set oFile = Nothing
            FileProperties = true
        else
            FileProperties = false
        end if
    end if

    set oFS = Nothing
end Function

Function FileReadLine( oFile, sLineOfFile )
    if not oFile.AtEndOfStream then
        sLineOfFile = oFile.ReadLine()
        FileReadLine = true
    else
        FileReadLine = false
    end if

end Function

Using above to two function, I want to read content from file,
so I wrote following script -
VB
Dim fs1, fs2, fs3

sFileName = server.mappath("/db/remoteinfo.txt")
call FileProperties( sFileName, sLength, sDateTime, sAttr)

response.write "Length -  " & sLength 

call FileReadLine(oFile, sLineOfFile)

Here I get error message :
Microsoft VBScript runtime error '800a01a8'

Object required: 'oFile'

Please help me as it is very urgent.


Thanks in advance....
Posted
Updated 31-Jul-12 21:02pm
v2
Comments
Christian Graus 1-Aug-12 2:37am    
Don't tell us it's urgent. We are not being paid and won't answer quicker because you told us to.
nitintfs 1-Aug-12 2:42am    
Sorry and understand, will keep your suggestion in mind while posting next future questions..

1 solution

You have not posted anywhere that you call FileReadLine, but I am guessing that you didn't pass it in, or it's Nothing.

ASP is a nightmare, I would run from this project as fast as you can.
 
Share this answer
 
Comments
nitintfs 1-Aug-12 2:40am    
Thanks for immediate response, but I have used FileReadLine function -

Dim fs1, fs2, fs3

sFileName = server.mappath("/db/remoteinfo.txt")
call FileProperties( sFileName, sLength, sDateTime, sAttr)

call FileReadLine(oFile, sLineOfFile)
Christian Graus 1-Aug-12 2:41am    
OK - as you posted that out of all context, I can't see what oFile would be at that point in time, but your error makes me think it is 'nothing'. If you were using a real web development platform, you could debug it. As it stands, I'd add code to do a response.write to tell you the state of the object.
nitintfs 1-Aug-12 2:49am    
Thanks again!

oFile is declared in FileProperties, and I expect it be passed as reference in FileReadLine function as it is.

Because if I use following statement, it works
response.write " Length - " & sLength & ", Attribute - " & sAttr & ", Date - " & sDateTime

But when oFile return "NULL"
nitintfs 1-Aug-12 2:56am    
Can you suggest any sort of clue to debug this code ?
Christian Graus 1-Aug-12 3:43am    
I reiterate, asp is a nightmare. But, you can write code that uses response.write to emit text based on things like the state of oFile, to tell you what is going wrong.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900