Code: Writing Text to a File (Visual Basic),CodeWri,odeWrit,deWriti,eWritin,Writing,WritingT,ritingTe,itingTex,tingText,ingTextt,ngTextto,gTexttoa,TexttoaF,exttoaFi,xttoaFil,ttoaFile,toaFileV,oaFileVi,aFileVis,FileVisu,ileVisua,leVisual,eVisualB,VisualBa,isualBas,sualBasi Code: Writing Text to a File (Visual Basic)----编程资料集中营--八角123--bajiao123.com
编程资料集中营
 | 网站首页 | 文章中心 | 编程资料2 | 软件下载 | BT下载 | 八卦星闻 | 音乐在线 | 在线游戏 | 免费电影 | 进入问吧 | 
Code: Writing Text to a File (Visual Basic),ThisexamplewritesastringtoatextfileusingtheWriteLinemethodoftheStreamWriterclass.ExampleDimfileAsNewSystem.IO.StreamWriter("c:\test.txt")file.WriteLine("Hereisthefir,
您现在的位置: 编程资料,学习资料,c,c++,vc,vc++,java,jsp,j2ee,j2me,asp,php >> 文章中心 >> .NET 专区 >> NET 技术 >> 文章正文
【字体:
Code: Writing Text to a File (Visual Basic)   进入问吧

本站地址:http://www.bajiao123.com

作者:admin    文章来源:本站    点击数:    更新时间:2007-6-10    

Code: Writing Text to a File (Visual Basic)

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.


   

进入问吧

本站地址:http://www.bajiao123.com

文章录入:admin    责任编辑:admin 
高级搜索
编程资料集中营