3
Contributors
6
Replies
8
Views
4 Years
Discussion Span
Last Post by Pride
0

Hi,

You can do it like this:

Imports System.Windows.Forms

public class FileOpenDialogFilter
   public Shared Sub Main
        Dim saveFileDialog1 As System.Windows.Forms.SaveFileDialog

        saveFileDialog1 = New System.Windows.Forms.SaveFileDialog()

        saveFileDialog1.CreatePrompt = True
        saveFileDialog1.FileName = "doc1"

        saveFileDialog1.Filter = "Word (*.doc) |*.doc;*.rtf|(*.txt) |*.txt|(*.*) |*.*"
        If saveFileDialog1.ShowDialog() = DialogResult.OK Then
            Console.WriteLine(saveFileDialog1.FileName)
        End If
   End Sub
End class
0

'Imports' statements must precede any declarations. C:\Documents and Settings\Administrator\Desktop\555\source\NET\Wtxt\ReAder.vb 71 1 WinEx

0

no wait...it simply cant save the file...no errors at all

0

First of all i don't understand why everyone uses IO, i understand no one used it here though.

Anyways. Try this:

Public Class MyForm

    Private Sub MyForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        MySaveFileDialog.Filter = "Text File|*.txt"
    End Sub

    Private Sub MyButton_Click(sender As Object, e As EventArgs) Handles MyButton.Click
        If MySaveFileDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
            My.Computer.FileSystem.WriteAllText(MySaveFileDialog.FileName, MyTextBox.Text, False)
        End If
    End Sub
End Class

Edited by Pride

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.