ASP.NET´´½¨Îļþ²¢Ð´ÈëÄÚÈÝ
ÔÚASP.NETÖУ¬Îļþ´¦ÀíµÄÕû¸ö¹ý³Ì¶¼ÊÇΧÈÆ×ÅSystem.IO Õâ¸öÃû³Æ¿Õ¼äÕ¹¿ªµÄ¡£Õâ¸öÃû³Æ¿Õ¼äÖоßÓÐÖ´ÐÐÎļþ¶Á¡¢Ð´ËùÐèÒªµÄÀà¡£±¾ÎÄ´Ó×î»ù±¾µÄ²Ù×÷¿ªÊ¼£¬½âÊÍÔÚASP.NETÖÐÎļþ´¦ÀíµÄ¸ÅÄ°üÀ¨Èç´ÓÒ»¸öÎļþÖжÁÈ¡ÄÚÈÝ¡¢ÈçºÎÏòÒ»¸öÎļþÖÐдÈëÄÚÈݺÍÈçºÎɾ³ýÒ»¸öÎļþ¡£¡¡¡¡
Ç°ÃæÒѾÌáµ½£¬ÒªÏëÔÚASP.NET Ò³ÃæÖнøÐÐÎļþ´¦Àí£¬±ØÐëÒªÓÐ"System.IO"Ãû³Æ¿Õ¼ä¡£ËùÒÔ£¬µÚÒ»²½¾ÍÊÇÒýÈëÕâ¸öÃû³Æ¿Õ¼ä£º
<%@ Import Namespace="System.IO" %>
ÏÂÒ»²½£¬¾ÍÊÇ´´½¨Ò»¸öÎı¾Îļþ£¬²¢½«Õâ¸öÎı¾Îļþ·ÖÅä¸øÒ»¸öÁ÷Êéд¶ÔÏó£¬ÕâÑù¾Í¿ÉÒÔÏòÎı¾ÎļþÖÐдÈëÄÚÈÝÁË¡£ÓÃÒÔÏÂÒ»¶Î´úÂëÀ´Íê³ÉÕâ¸öÈÎÎñ£º
writefile.aspx
<%@ Import Namespace="System.IO" %>
<%
Response.write("Writing the content into Text File in ASP.NET<BR>")
'ÉùÃ÷Á÷Êéд¶ÔÏó
Dim strwriterobj As StreamWriter
' ´´½¨Îı¾Îļþ£¬·ÖÅätextfile¶ÔÏó
strwriterobj= File.CreateText("c:aspnet.txt" )
' дÈëÄÚÈÝ
strwriterobj.WriteLine( "Welcome to wonderfull world of ASP.NET Programming" ) '
Íê³É²Ù×÷£¬¹Ø±ÕÁ÷¶ÔÏó
strwriterobj.Close
Response.write("Done with the creation of text file and writing content into it")
%>
ÕâÑù¾ÍÍê³ÉÁË£¡ÏÖÔÚÈÃÎÒÃǼÌÐø½øÐÐÏÂÒ»¸öÈÎÎñ£¬´Ó¸Õ²Å´´½¨µÄÎı¾ÎļþÖжÁÈ¡ÄÚÈÝ¡£
´ÓÎļþÖжÁÈ¡ÄÚÈÝ
´ÓÎļþÖжÁÈ¡ÄÚÈÝÓëÏòÎļþÖÐдÈëÄÚÈÝ´óÖÂÏàͬ£¬Ö»ÊÇҪעÒâÒ»ÏÂÏÂÃæµÄÁ½¼þÊ£º
1. Îļþ¶ÁȡʹÓÃStreamReaderÀà 2. µ±Ê¹ÓÃÁËReadline·½·¨Ê±£¬½«Òª±»¶ÁÈ¡µÄÎı¾ÎļþµÄ½áβ´¦»áÓÃÒ»¸ö¿Õ×Ö·û´®("")À´±ê¼Ç¡£
ÏÖÔÚ¿ªÊ¼±àд´úÂë´ÓÇ°Ãæ´´½¨µÄaspnet.txt ÎļþÖжÁÈ¡ÄÚÈÝ£º
readfile.aspx
<%@ Import Namespace="System.IO" %>
<%
Response.write("Reading the content from the text file ASPNET.TXT<br>")
' ´´½¨Á÷¶ÁÈ¡¶ÔÏó
Dim streamreaderobj As StreamReader
' ÉùÃ÷±äÁ¿£¬ÒÔ´æ·Å´ÓÎļþÖжÁÈ¡µÄÄÚÈÝ
Dim filecont As String
' ´ò¿ªÎı¾Îļþ£¬·ÖÅä¸øÁ÷¶ÁÈ¡¶ÔÏó
streamreaderobj = File.OpenText( "c:aspnet.txt" )
' ÖðÐжÁÈ¡ÎļþÄÚÈÝ
Do
filecont = streamreaderobj.ReadLine()
Response.Write( filecont & "<br>" )
Loop Until filecont = ""
' Íê³É¶ÁÈ¡²Ù×÷ºó£¬¹Ø±ÕÁ÷¶ÁÈ¡¶ÔÏó
streamreaderobj.Close
Response.write("<br>Done with readi
Ïà¹ØÎĵµ£º
×î½üÅöµ½Ò»ÎÊÌ⣬ÐèÒªÔÚASP.NetºÍJavaScriptÖд«µÝÊý¾Ý¡£¾ßÌåµÄÐèÇóÊÇÕâÑùµÄ£¬Ò³Ãæpostbackºó½«»áload JS£¬µ«ÊÇÐèÒª¼Çס֮ǰij¸ö״̬£¬Õâ¸ö״̬ÊÇÖ¸JSµÄ״̬£¬Ò²¾ÍÊÇ˵load JSºó£¬»¹Òª¼Çס֮ǰµÄ״̬£¬¶ø²»Êǻص½Ä¬ÈϵÄ״̬¡£
Ò»¿ªÊ¼ÏëÁ˺ܶà°ì·¨£¬µ«¶¼²»³É¹¦£¬ºóÀ´ÎÊÁËÎÊͬÊ£¬·¢ÏÖ¿ÉÒÔͨ¹ýÒþ²ØµÄ±íµ¥ÔªËØÀ´´«µÝÊý¾Ý£¬ËùÒ ......
ÔÚASP.NETÍøÕ¾¿ª·¢ÖпÉÄÜ»áÓöµ½Òª¸ü»»Êý¾Ý¿â£¬È罫Aceess»»ÎªSQL Server £¬ÓÉÓÚAceessÒýÓÃSystem.Data.OleDbÃüÃû¿Õ¼ä£¬SQL ServerÒýÓÃSystem.Data.SqlClientÃüÃû¿Õ¼ä¡£ÔÚÒ»°ã³ÌÐò´úÂëÖÐÎÒÃÇÐèÒª¸ü¸ÄÁ¬½Ó×Ö·û´®£¬ADO.NETÊý¾Ý·ÃÎÊÃüÁî¶ÔÏó£¬×îÂé·³µÄÊDz»Í¬Êý¾Ý¿âÓи÷×Ô²»Í¬SqlÃüÁî¡£ÎÒÃÇ¿ÉÒÔʹÓóéÏ󹤳§Ä£Ê½ÊµÏÖASP.NET·ÃÎʲ ......
1¡¢ÀàÊÇÒýÓÃÀàÐÍ£¬½á¹¹ÔòÊÇÖµÀàÐÍ¡£Òò´Ë½á¹¹ÊÇ·ÅÔÚÕ»£¨Stack£©ÀÀàÔò½ö½öÊǽ«ÒýÓõØÖ·´æ·ÅÔÚÕ»À¶ø¾ßÌåµÄÖµÔò´æ·ÅÔڶѣ¨heap£©Àï¡£
2¡¢¾ÝµÚ1µã¿ÉÒԵóö½áÂÛ£¬ÄǾÍÊÇÀà¶ÔÏóͨ³£ÓÃÀ´´«µÝ´óÊý¾Ý£¬¶ø½á¹¹¶ÔÏóÔòÓÃÀ´´«µÝСÊý¾Ý¡£
3¡¢Àà¿ÉÒԼ̳кͱ»¼Ì³Ð£¬¶ø½á¹¹Ôò²»Ö§³Ö¡£µ«½á¹¹ºÍÀàÒ»Ñù¿ÉÒԼ̳Ð×Ô½Ó¿Ú¡£
4¡¢½á¹¹¶ÔÏó²»ÄÜ ......
ASP.NET³ÌÐòÖг£ÓôúÂë»ã×Ü
1.×Ô¶¨ÒåÒì³£´¦Àí
//×Ô¶¨ÒåÒì³£´¦ÀíÀà
using System;
using System.Diagnostics;
namespace MyAppException
{
¡¡/// £¼summary£¾
¡¡/// ´ÓϵͳÒì³£ÀàApplicationException¼Ì³ÐµÄÓ¦ÓóÌÐòÒì³£´¦ÀíÀà¡£
¡¡/// ×Ô¶¯½«Òì³£ÄÚÈݼǼµ½Windows NT/2000µÄÓ¦ÓóÌÐòÈÕÖ¾
¡¡/// £¼/summary£¾
......
×î½üд³ÌÐòÒ»Ö±³öÎÊÌ⣬ÒÔÇ°Ò»¸öÕ¾Èý¼¸Ìì¾ÍÇáËɸ㶨£¬ÏÖÔÚÒ»¸öÄ£¿é¾³£¸ã°ëÌ죬NND
ÏÂÎ翪·¢¿áÒ×»¯×±Æ·É̳Ç(http://www.koyee.net)Ò»¸ö±íµ¥Ìá½»¹¦ÄÜÄ£¿é£¬±¾µØÈκÎÎÊÌⶼûÓÐÁË£¬´«µ½·þÎñÆ÷Éϱ¾ÒÔΪûÊÂÁË£¬ºóÀ´Ò»¼ì²éËùÓеÄÑéÖ¤¿Ø¼þ¶¼²»Æð×÷ÓÃÁË£¬Ö±½Ó¶¼Ìá½»¹ýÈ¥ÁË£¬ÓôÃÆ£¬ÔÒÔΪ³ÌÐò±»¸Ä´íÁË£¬¼ì²é±¾µØ»¹ÊÇûÈκÎÎÊÌ⣬¼ ......