Im trying to save a file in XML and offer the user a save dialog to appear so they can name the file. The file will save using a custom file extention. The problem is I keep getting off the wall suggestions and Im looking for a simple solution. Here is what I have, please only show examples using my syntax based code. Im still a bit new to Vb so posting off the wall examples will not help in any way shape or form thank you.
Code:Private FileDialog As SaveFileDialog Public Sub New() InitializeComponent() FileDialog = New SaveFileDialog() FileDialog.Filter = "UOK Application | *.App" FileDialog.DefaultExt = "app" End Sub Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click Dim AppSerializer As Xml.Serialization.XmlSerializer = New Xml.Serialization.XmlSerializer(GetType(Storage)) Dim fileStream As System.IO.Stream = FileDialog.OpenFile() Dim SW As New System.IO.StreamWriter(FileDialog) SaveFileDialog1.ShowDialog() AppSerializer.Serialize(SW, Storage) SW.Close() Me.Update() End Sub




Reply With Quote