Need Help for FileWrite

lucas555

Member
Licensed User
Longtime User
B4X:
Private Sub SaveCrn()
        Dim strBuildCrn As String
        Dim strFile As String
        Dim I As Number

        strFile = strReturnsPath & "\PrReturns.CRN"
        strBuildCrn = ""
       
        For I = 0 To ArrayLen(arrReturns()) - 1
            strBuildCrn = strBuildCrn & arrReturns(I).ProductCode & _
                          ", " & arrReturns(I).Quantity & _
                          ", " &  arrReturns(I).Comments & CRLF
        Next I
       
        If FileExist(strFile) Then
            FileOpen (c1, strFile, cRead,, cASCII)
            FileWrite(c1, strBuildCrn)
            FileClose(c1)
            Msgbox("The changes have been saved properly", "SAVED", cMsgboxOK, cMsgboxExclamation)
        Else
            Msgbox("The changes have not been saved properly because the File : " & strFile & " is missing.",                          "ERROR", cMsgboxOK, cMsgboxExclamation)
        End If
    End Sub

It's giving me an error a the FileWrite(c1, strBuildCrn) line.

Error : Unable to cast object of type "Dbasic.Other.CStreamReader" to type "System.IO.StreamWriter"

Is there another instruction to write the file ?
 

lucas555

Member
Licensed User
Longtime User
Please Ignore this Thread, I just found out my stupidity.

For further reference, I opened the file in cRead, it should have been cWrite ><

Thanks anyways :)
 
Top