Section A.2. Disk IO: Writing


A.2. Disk I/O: Writing

The "Save a File" button displays a Save File dialog window to let users specify a directory as well as a filename. Once you've selected these two items, you will save the current date and time to the specified file:

 '===================================================     ' Save a File     '===================================================     Private Sub btnSaveFile_Click( _        ByVal sender As System.Object, _        ByVal e As System.EventArgs) _        Handles btnSaveFile.Click         '---Create a SaveFileDialog to request a path and file         ' name to save to---         Dim saveFile1 As New SaveFileDialog()         '---Initialize the SaveFileDialog to specify the txt         ' extension for the file---         saveFile1.DefaultExt = "*.txt"         saveFile1.Filter = "Text Files|*.txt"         '---Determine if the user selected a file name from the         ' saveFileDialog---         If (saveFile1.ShowDialog() = _             System.Windows.Forms.DialogResult.OK) _             And (saveFile1.FileName.Length) > 0 Then             '---Write the current date and time to file---             My.Computer.FileSystem.WriteAllText( _                saveFile1.FileName, Now.ToString, False)             MsgBox("Content written to text file.")         End If     End Sub 




Use ClickOnce to Deploy Windows Applications2006
Use ClickOnce to Deploy Windows Applications2006
ISBN: N/A
EAN: N/A
Year: 2005
Pages: 38

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net