
it seems to be working now..i think it might have been because i didnt close some streamreader..
anyway here is the new code... nothing much has change....the error was "The file your accessing is currently being used" (i had to translate that since it was in japanese)....
by the way the strEdyFile is a string...this was the declaration dim strEdyFile() as string....since i dont know
many record each process may contain i used the i integer to count every loop and ReDim the array while preserving the old record...is this a bad practice?...well thanks a lot...
CODE
'this is inside a thread procedure
ReDim Preserve strEdyFile(i)
strEdyFile(i) = strTemp(1)
'check for Distinct Value
bolDistinctEdy = DISTINCTEdy(strEdyFile(i))
If bolDistinctEdy = False Then
CheckInputData = False
intTempError += 1 'count error
ReDim Preserve strTempError(intTempError)
'saved error in array
strTempError(intTempError) = "Error" & strTemp(1)
End If
'in module
'global function region
Public Function DISTINCTEdy(ByVal strEdyNo As String) As Boolean
Dim streamEdyRead As StreamReader
Dim strTemp(),strTempFile As String
strTempFile = cnsCreateFile & "\AllEdy\AllEdy.CSV" 'cnsCreateFile is some global constant
DISTINCTEdy = True
Try
If File.Exists(strTempFile) = True Then
streamEdyReader = New StreamReader(strTempFile)
Do While streamEdyRead.Peek >= 0
Dim strOneRow As String = streamEdyRead.ReadLine
If strOneRow = "" Then
Exit Do
End If
strTemp = strOneRow.Split(",")
If strEdyNo = strTemp(1) Then
DISTINCTEdy = False
Exit Do
End If
Loop
streamEdyRead.Close() 'close stream to write new record
else
DISTINCTEdy = False
Exit Try
end if
Catch
DISTINCTEdy = False
finally
If DISTINCTEdy = true Then 'double record will not be saved a
Dim streamEdyWrite As New StreamWriter (cnsCreateFile& "\AllEdy\AllEdy.CSV")
streamEdyWrite.WriteLine(strEdyNo) 'save all record in
streamEdyWrite.Close()
Endif
end try
End Function
[/quote]
This post has been edited by larimore: 18 Mar, 2007 - 11:56 PM