Writing text to a file (Visual Basic)

xiaoxiao2021-03-06  17

.

EXAMPLE

Dim file as new system.io.streamwriter ("c: /test.txt")

File.writeline ("Here Is The First Line.")

File.close ()

Compiableing 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 (tabindex = "0" keywords = "frlrfSystemIOIOExceptionClassTopic"> IOException Class). The disk is full (tabindex = "0" keywords = "frlrfSystemIOIOExceptionClassTopic"> IOException Class). The pathname is too long ( TabINDEX = "0" keywords = "fr1rfsystemiopathtoolongexceptionclasstopic"> 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 tabindex = "0" keywords = "vxconAccessControl"> 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.

转载请注明原文地址:https://www.9cbs.com/read-41623.html

New Post(0)