Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

bad file name or permission denied

Status
Not open for further replies.

antonyb

MIS
Aug 23, 2002
35
MY
hi,

i just can't figure out what's wrong with my code.My program always come across this error, but can't understand why it has occurred. No matter in client side or at my own local also the same.

could somebody guide me on this problem.

below is my code:

Public Sub checkrecord()
Dim intIconNum As Integer
Dim strInRecord As String
Dim lFileNum As Long, lFileNum1 As Long, lfilenum2 As Long
Dim strFileName As String
Dim strCompare As String
Dim RetVal
Dim dummy As String
Dim dummy1 As String
Dim bfound As Boolean
Dim itmRecord As ListItem

On Error GoTo ErrHandler

'add the columns


frmmain.ListView1.ColumnHeaders.Clear
frmmain.ListView1.ListItems.Clear

frmmain.ListView1.VIEW = lvwReport
frmmain.ListView1.ColumnHeaders.Add , , "Station"
frmmain.ListView1.ColumnHeaders.Add , , "Alert Log Path", 3000
frmmain.ListView1.ColumnHeaders.Add , , "Alert Log Status", 1500
frmmain.ListView1.ColumnHeaders.Add , , "Last Check", 2100
frmmain.ListView1.ColumnHeaders.Add , , "Error Found", 5000

'set the image list to use for the icons
Set frmmain.ListView1.Icons = frmmain.ImageList1
Set frmmain.ListView1.SmallIcons = frmmain.ImageList1

strCompare = "exclude.ini"
'set the file name to read
strFileName = &quot;path.ini&quot; '<= CHANGE
'get the next available file number
lFileNum = FreeFile

RetVal = Shell(runbatch, vbMinimizedFocus)
WritePanel 2, &quot;checking running....&quot;, &quot;\images\access.ico&quot;

'open the file
Open strFileName For Input As #lFileNum
'loop until the end of the file
Do While Not EOF(lFileNum)

'read the next available line
Line Input #lFileNum, strInRecord

'if the line is not empty
If strInRecord <> &quot;[NETWORK PATH]&quot; Then
If strInRecord <> &quot;&quot; Then
'split the line into an array based on the = delimiter
strFields = Split(strInRecord, &quot;=&quot;)

'choose the appropriate icon
Select Case strFields(0)
Case &quot;MLYSITE&quot;
intIconNum = 1
Case &quot;MLYMTF&quot;
intIconNum = 1
Case &quot;MLYMAC&quot;
intIconNum = 1
Case Else
intIconNum = 1
End Select

'add an item to the listview, with the first field as the text with the icon
Set itmRecord = frmmain.ListView1.ListItems.Add(, , strFields(0), intIconNum, intIconNum)

'add the other field to the list item
itmRecord.ListSubItems.Add , , strFields(1)
If CheckFileExist(strFields(1)) Then
If Dir(datalog, vbDirectory) = &quot;&quot; Then
FileSystem.MkDir datalog
End If

FileCopy strFields(1), datafile
'Delay (1)
lFileNum1 = FreeFile
Open datafile For Input As #lFileNum1
Do While Not EOF(lFileNum1)
Line Input #lFileNum1, dummy

If UCase(Mid(dummy, 1, 4)) = &quot;ORA-&quot; Then
'--------------------------------------------
'added by khleng
'--------------------------------------------
lfilenum2 = FreeFile
bfound = False
Open strCompare For Input As #lfilenum2
Do While Not EOF(lfilenum2)
Line Input #lfilenum2, dummy1
If UCase(Mid(dummy, 1, 9)) = UCase(dummy1) Then
bfound = True
Exit Do
End If
Loop
Close #lfilenum2
If Not bfound Then
itmRecord.ListSubItems.Add , , dummy
itmRecord.SmallIcon = &quot;alert&quot;
Alert.Show
Else
bfound = False
End If


End If


Loop

Close #lFileNum1

itmRecord.ListSubItems.Add 2, , &quot;File Available&quot;
itmRecord.ListSubItems.Add 3, , Format(Now, &quot;dd/mm/yyyy/ hh:mm:ss AMPM&quot;)
Else

itmRecord.ListSubItems.Add 2, , &quot;File Not Available&quot;
itmRecord.ListSubItems.Add 3, , Format(Now, &quot;dd/mm/yyyy/ hh:mm:ss AMPM&quot;)
itmRecord.SmallIcon = &quot;warning&quot;

End If

'clean up
Set itmRecord = Nothing

End If
End If
Loop

'WritePanel 3, &quot;Next run on &quot; & Format(Now + 1, &quot;DD/MM/YYYY HH:MM:SS AMPM&quot;)
'close the file
Close #lFileNum

WritePanel 2, &quot;System Started&quot;
Exit Sub
ErrHandler:
MsgBox &quot;CheckRecord Module Error. &quot; + Err.Description
End Sub



thanks


antony

 
Antony, you post is too long. Only post the relevant code. Post error message (whjich you partly have done in the subject) and indicate in which line the error occurs. Read faq222-2244 Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top