-2
我有下面的代碼,它沒有做我想做的事。誰能幫忙? 這是一個計時器事件項目。該應用程序正在收集價值並將其寫入.csv文件。在Visual Basic中重命名文件
這就是我要做的:
- 如果.txt文件丟失,重命名格式爲* .csv .TXT
- 重命名格式爲* .csv txt文件,(每當.TXT文件丟失重命名格式爲* .csv TXT) - >這是行不通的
如果.CSV缺少創造新的,並繼續追加到它 - >這是工作
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
它正在做什麼? –
這不是重命名.csv文件 – Smoky2016
你的問題沒有多大意義....你想達到什麼目的? – Werdna