I have the following code, it is not doing what I want it to do. Can anyone help? This is a timer event project. The application is collecting value and writing it to the .csv file.
This is what I am trying to do:
- If .txt file is missing, rename the .csv as .txt
- rename .csv as .txt,(Whenever .txt file is missing rename .csv as txt)--> this is not working
If .csv is missing create new one and continue to append to it--> this is working
Try 'Check for .csv file If My.Computer.FileSystem.FileExists(csv_File) = False Then Else 'if file does not exist, create new file to start writing to it My.Computer.FileSystem.WriteAllText(csv_File, vbCrLf & Today & "," & Tag_name_Read & "," & itemValues(0).Value.ToString, True) End If If My.Computer.FileSystem.FileExists(txt_File) = False Then FileOpen(1, csv_File, OpenMode.Output) FileClose(1) 'Check for .txt If File.Exists(txt_File) = False Then ' Change ".CSV" to the path and filename for the file that My.Computer.FileSystem.RenameFile(csv_File, txt_File) End If End If Catch ex As Exception End Try