hey guys. If the user chooses to save over an existing file, I want to essentially delete the file first, then re-create it and save to it. Basically, I don't want to append to the file. I want to completely overwrite. However, I am just running into all these snags. It basially deletes the file as soon as the savefiledialog box opens. before, it would simply append. Can anyone spot my problem?code Code:
Try With SaveDataLogDialog .FileName = DFileName If File.Exists(DFileName) = True Then File.Delete(DFileName) End If .Filter = "CSV files (*.csv)|*.csv|" & "All files|*.*" .DefaultExt = "csv" .AddExtension = True .CreatePrompt = True .OverwritePrompt = True .Title = "Save Data Log As..." If .ShowDialog() = DialogResult.OK Then DFileName = .FileName End If End With Catch es As Exception MessageBox.Show(es.Message) Finally If Not (sw Is Nothing) Then datalogSW.Close() End If End Try




Reply With Quote