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:
  1. Try
  2.             With SaveDataLogDialog
  3.                 .FileName = DFileName
  4.                 If File.Exists(DFileName) = True Then
  5.                     File.Delete(DFileName)
  6.                 End If
  7.  
  8.                
  9.                 .Filter = "CSV files (*.csv)|*.csv|" & "All files|*.*"
  10.                 .DefaultExt = "csv"
  11.                 .AddExtension = True
  12.                 .CreatePrompt = True
  13.                 .OverwritePrompt = True
  14.                 .Title = "Save Data Log As..."
  15.  
  16.            
  17.                 If .ShowDialog() = DialogResult.OK Then
  18.                  
  19.                     DFileName = .FileName
  20.  
  21.                 End If
  22.  
  23.             End With
  24.         Catch es As Exception
  25.             MessageBox.Show(es.Message)
  26.         Finally
  27.             If Not (sw Is Nothing) Then
  28.                 datalogSW.Close()
  29.             End If
  30.         End Try