首页 > 开发 > 综合 > 正文

Code: Writing Text to a File (Visual Basic)

2024-07-21 02:20:45
字体:
来源:转载
供稿:网友

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:/test.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.
,欢迎访问网页设计爱好者web开发。
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表