* In todays class we talked about file handling (working with simple text files).
* We talked about performing tasks such as creating, writing, reading, deleting, moving and copying the text files.
* We had to import the class library for StreamReader and StreamWriter to the application as it was not automatically included: Imports System.IO
* We then added code to the click event of each button on our form to perform the desired task, e.g.
1. btnCreateFile - File.Create("C:\mycreatefile.txt")
2. btnWriteFile - Dim objWriter As New StreamWriter("C:\mywritefile.txt")
objWriter.WriteLine("I am NOT a multimedia rockstar!")
objWriter.Close()
3. btnReadLine - Dim objReader As StreamReader
objReader = File.OpenText("C:\mywritefile.txt")
txtFileContents.Text = objReader.ReadLine()
objReader.Close()
4. btnReadFile - as btnReadLine except .ReadToEnd() replaces .ReadLine()
5. btnMoveFile - File.Move ("C:\mycreatefile.txt", "E:\Chisholm\Rachael\mycreatefile.txt")
6. btnCopyFile - File.Copy("C:\mywritefile.txt", "E:\Chisholm\Rachael\mywritefile.txt")
7. btnDeleteFile - File.Delete("E:\Chisholm\Rachael\mywritefile.txt")
Element Naming Techniques in ASP.NET
15 years ago

No comments:
Post a Comment