Code: Writing Text to a File (Visual Basic)

Source: Internet
Author: User

This example writes a string to a text file using the WriteLine method of the StreamWriter class.
Example
Dim file As New System. IO. StreamWriter ("c: est.txt ")
File. WriteLine ("Here is the first line .")
File. Close ()
Compiling the Code
This example requires:
A reference to System namespace. Robust Programming
The following conditions may cause an exception:
The file exists and is read-only (IOException Class). The disk is full (IOException Class). The pathname is too long (PathTooLongException Class). Security
This example creates a new file, if the file does not already exist. if an application needs to create a file, that application needs Create access for the folder (see Access Control ). if the file already exists, the application needs only Write access, a lesser privilege. where possible, it is more secure to create the file during deployment, and only grant Read access to a single file, rather than Create access for a folder.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.