Code.GeekInterview.com
 
Code Samples VB.NET
 

Creating Text files using VB.NET FileStreams.


Code ResourceAuthor: jsubha2009  

Difficulty Level: Beginner

Published: 6th Jan 2010   Read: 5844 times  

Filed in: VB.NET
Add Comment


 

 

Sponsored Links


 

 
This code contains the necessary steps to be followed to create a textfile in C: directory using VB.NET Console Application.All the text entered in the console is stored in the file by name Newfile.txt.When the user types the word "exit" in a new line the file gets closed.We can see the information which we typed in the Console in the file placed at C:Newfile.txt. Happy Programming.
 


Sample Code
  1. Imports System
  2. Imports System.IO
  3. Module Module1
  4.  
  5.     Sub Main()
  6.         Dim fs As New FileStream("C:Newfile.txt", FileMode.Create, FileAccess.Write)
  7.         Dim sw As StreamWriter
  8.         sw = New StreamWriter(fs)
  9.         Dim str As String
  10.         Console.WriteLine("Enter text.Type 'exit' to stop")
  11.         str = Console.ReadLine()
  12.         While (str.Equals("exit") = False)
  13.             sw.Write(str)
  14.             str = Console.ReadLine()
  15.         End While
  16.         sw.Close()
  17.         fs.Close()
  18.         Console.WriteLine("End of Text")
  19.         Console.ReadLine()
  20.     End Sub
  21.  
  22. End Module
  23.  
Copyright GeekInterview.com


Next Article: Remove Blank Lines from Script Files


 

Latest Code Samples

 

Popular Code Samples

 

Related Code Samples

 

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    



Popular Coders

# Coder NameHits
1. Lokesh9477
2. jsubha20095845
3. supersubra5831
4. Lokesh M4627
5. sureshrndsoft3663
6. Biswabed Dash2394
7. alaa_eng1891

Active Coders

# Coder NameCodes
1. supersubra1
2. Biswabed Dash1
3. Lokesh1
4. Lokesh M1
5. jsubha20091
6. sureshrndsoft1
7. alaa_eng1

Refined Tags