[RESOLVED] deleting a file
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
Re: [RESOLVED] deleting a file
Doh!! I think I saw that, but just never said anything, as I thought you were setting it elsewhere as well.
Glad you got it sorted!
Gary
Re: [RESOLVED] deleting a file
haha. you did say it in post #8 now that I look back. I don't know why I didn't try it sooner. I think I just figured that's what I did because the way I had it made absolutely no sense. It's alright though--everyone got rep! haha