[2005] streamWriter giving error 'Access Denied' to files created already
If I have
Code:
Private Sub myform_load(byVal sender As Object, byVal e As EventArgs) Handles MyBase.load
Dim sw As New StreamWriter("myurl") 'this will create file in debug folder
sw.write("Sup yo")
sw.close()
End Sub
If I run that again, will that erase the previous file created? or will it just edit it and write 'Sup yo' in it?
If so can someone tell me how to write to a file that exists already?
Re: [2005] streamWriter giving error 'Access Denied' to files created already
Check out the 2nd overload, it specifies if you want to append or not. If set to True then it will simply add text. If false, it will overwrite. Don't forget the file extension either. And if using 2005, then you can implement "Using" which will dispose of the streamwriter for you after.
2 Code:
Using sw As New IO.StreamWriter("myurl.txt", True) 'this will create file in debug folder
sw.Write("Sup yo")
sw.Close()
End Using