当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > Code: Writing Text to a File (Visual Basic)

ASP.NET
在ASP.NET中进行文件处理(1)
ASP.NET的实时天气及24小时天气预报
ASP.NET画图全攻略(上)
ASP.NET画图全攻略(下)
ASP.NET学习篇(1)——开篇
ASP.NET学习篇(2)——安装与配置
ASP.NET学习篇(3)——几个简单的ASP.ENT的例子
ASP.NET学习篇(4)——服务器端的控件
ASP.NET立即上手教程(1)
ASP.NET立即上手教程(2)
ASP.NET立即上手教程(3)
ASP.NET立即上手教程(4)
ASP.NET立即上手教程(5)
ASP.NET立即上手教程(6)
ASP.NET立即上手教程(8)
ASP.NET立即上手教程(7)
ASP.NET立即上手教程(9)
ASP.NET立即上手教程(10)
ASP.NET立即上手教程(11)
ASP.NET立即上手教程(12)

ASP.NET 中的 Code: Writing Text to a File (Visual Basic)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 48 ::
收藏到网摘: n/a


This example writes a string to a text file using the WriteLine method of the StreamWriter class.ExampleDim 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.