SaveFile with Filter extension???

Getox

Centurion
Joined
Jul 8, 2004
Messages
122
i cant get this working at all

all it does is say it has illegal letters

Code:
        SaveFileDialog.Title = ("Save File")
        SaveFileDialog.Filter = ("HTML (*.html*)|*.html*|HTM (*.htm*)|*.htm*|XHTML (*.xhtml*)|*.xhtml*|XML (*.xml*)|*.xml*|PHP (*.php*)|*.php*|PHP3 (*.php3*)|*.php3*|PHP4 (*.php4*)|*.php4*|PHTML (*.phtml*)|*.phtml*|ASP (*.asp*)|*.asp*|ASPX (*.aspx*)|*.aspx*")
        Me.SaveFileDialog.ShowDialog()
        Dim oFile As System.IO.File
        Dim oWrite As System.IO.StreamWriter
        oWrite = oFile.CreateText(SaveFileDialog.FileName & "." & SaveFileDialog.Filter)
        oWrite.WriteLine(TextBox.Text)
        oWrite.Close()
 
Without getting into editting, here's an example of a SaveFile method.

Visual Basic:
With SaveFileDialog1
    .InitialDirectory = 'some directory
    .Filter = "Volts worksheet (*.elc)|*.elc|Binary (*.bin)|*.bin"
    .DefaultExt = "elc"
    .Title = "Save File As"
    .FileName = 'your file name
End With
If SaveFileDialog1.ShowDialog() = DialogResult.Cancel Then
     'blah
Else
     SaveListView(SaveFileDialog1.FileName)
     worksheetName = FilenameOnly(SaveFileDialog1.FileName)
     Add_2OpenedFiles(SaveFileDialog1.FileName)
     worksheetModified = False
End If

Hope that gives you some ideas.
Dan
 
all i want is someone to tell me how to get the app to save it as "File.Extenstion"
and not "File"
 
If you made your original question clearer then you may have got the answer you were after, saying that DiverDan's suggestion of just using the Dialog's .FileName property should also include the extension.
 
but im using more than 1 extension
and if i set the DefaultExt it only saves it as that
EG
Code:
        SaveFileDialog.FileName = ("MyDoc1")
        SaveFileDialog.DefaultExt = "html"

saves it as:
MyDoc1.html
and if i select the ASP one it saves it as
MyDoc1.html
 
The filter is only used to restrict the files displayed in the dialog box - not to alter the final name entered by the user. The DefaultExt property is only applied to the file name if the user provides a filename without specifying an extension as documented in MSDN.
 
You have : "HTML (*.html*)|*.html*"
Remove the trailing * to give you
HTML (*.html)|*.html|
Do the same with all the other extensions.
 
Back
Top