ÔÚASP.NETÖÐÒýÈëÁËÃû×ֿռ䣬ÆäÖÐÎļþ²Ù×÷¶ÔÓ¦µÄÃû×Ö¿Õ¼äÊÇSystem.IO¡£Ãû×Ö¿Õ¼äºÍ¶¯Ì¬Á´½Ó¿âÓÐЩÀàËÆ£¬µ«ÊÇÃû×Ö¿Õ¼äÔÚÕû¸ö.netϵͳÖж¼¿ÉÒÔÓ¦Óá£ÔÚASP.NETµÄÒ³ÃæÖпÉÒÔʹÓÃ<%@import namespace=...%>À´ÒýÓÃÃû×ֿռ䡣ÔÚvb6ÖвÉÓÃfso¶ÔÎļþ½øÐвÙ×÷£¬ÔÚASP.netÖеÄÎļþ¶ÔÏóºÍfsoºÜÏàËÆ¡£
ÕâÀïÎÒ½éÉÜÒ»ÏÂfile¶ÔÏó£ºfile¶ÔÏóµÄ×÷ÓÃÖ÷ÒªÊÇ´´½¨ÎļþÁ÷¶ÔÏó¡£Í¨¹ýfile¶ÔÏó¿ÉÒÔ¶ÔϵͳÎļþ½øÐÐÈ«ÃæµÄ¹ÜÀí£¬¿ÉÒÔ´´½¨¡¢¸´ÖÆ¡¢É¾³ý¡¢Òƶ¯ºÍ´ò¿ªÎļþ
ÏÂÃæÎÒÃÅÊ×ÏÈ´´½¨Ò»¸öfile¶ÔÏó¡£
ÔÚASP.netÖУ¬¿ÉÒÔʹÓÃ2ÖÖ·½·¨À´´´½¨Ò»¸öfile¶ÔÏó¡£
(1)ʹÓÃdim Óï¾äÀ´´´½¨Ò»¸öfile¶ÔÏó
dim mikecatfile as file
mikecatfile.create("c:\mikecat.txt")
(2)ʹÓÃnewÓï¾äÀ´´´½¨file¶ÔÏó
dim mikecatfile as new file("c:\mikecat.txt")
Ò²¿ÉÒÔÕâÑù¶¨Òå
dim mikecatfile as file
mikecatfile=new file("c:\mikecat.txt")
´ó¼ÒÇë×¢ÒâASP.netÖÐÓõ½vbÓï·¨ÔÚ½øÐжÔÏó¸³ÖµÊ±²»ÔÙÐèҪʹÓÃsetÓï¾ä
file¶ÔÏóµÄÖ÷ÒªÊôÐÔ
ÔÚ¶Ôfile¶ÔÏó½øÐÐÎļþµÄ¶Áд²Ù×÷ʱ£¬Ö»ÒªÊ¹ÓÃ2¸öÊôÐÔ£ºlengthºÍname·Ö±ðΪÎļþµÄ³¤¶ÈºÍÎļþÃû×Ö¡£
file¶ÔÏóµÄÖ÷Òª·½·¨
file¶ÔÏóÓÐ9¸ö³£Óõķ½·¨
(1)create·½·¨ ¸Ã·½·¨ÓÃÓÚ´´½¨Ò»¸öÐÂÎļþ
function create(string) as filestream
ÆäÖÐstringΪËùÐèÒª´´½¨µÄÎļþµÄ·¾¶£¬·µ»Øfilestream¶ÔÏ󣬴˶ÔÏóΪÎļþµÄ¶ÁдÌṩͨµÀ
(2)delete·½·¨ ¸Ã·½·¨ÓÃÓÚɾ³ýÒ»¸öÒѾ´æÔÚµÄÎļþ
sub delete (string)
»òÕßsub delete()
Èç¹ûfile¶ÔÏó°üº¬ÓÐÎļþ²ÎÊý£¬¿ÉÒÔʹÓõڶþÖÖ·½·¨É¾³ýÎļþ¡£·ñÔòÖ»ÄÜÓõÚÒ»ÖÖ·½·¨À´É¾³ýÎļþ£¬string²ÎÊýÖ¸¶¨ËùҪɾ³ýµÄÎļþ·¾¶¡£
(3)copy·½·¨
¸Ã·½·¨ÓÃÓÚ½«Ò»¸öÎļþ¸´ÖƵ½Ò»¸öÐÂÎļþ
sub copy(source,destination)
sourceÖ¸¶¨Ô´ÎļþµÄ·¾¶£¬destinationÖ¸¶¨Ä¿µÄÎļþµÄ·¾¶¡£copy·½·¨Ö»ÔÊÐí¸´ÖÆÒ»¸öÒѾ´æÔÚµÄÎļþµ½Ò»¸öÐÂÎļþ£¬²»ÔÊÐí¸²¸ÇÒ»¸öÒѾ´æÔÚµÄÎļþ¡£
(4)createtext·½·¨
¸Ã·½·¨ÓÃÓÚ´´½¨Ò»¸öÐÂÎļþ£¬¸ÃÎļþ¿ÉÒÔ½øÐÐд²Ù×÷¡£
function createtext(string) as streamwriter
»òÕßfunction createtext() as streamwriter
·µ»ØÖµÎªstreamwriter¶ÔÏóÓÃÓÚÖ´ÐжÔÎļþµÄд²Ù×÷
ºÍcreate·½·¨²»Ò»ÑùµÄÊÇ£¬createtext·½·¨·µ»ØµÄ²»ÊÇfilestream¶ÔÏ󣬶øÊÇstreamwriter¶ÔÏó¡£
(5)fileexists·½·¨
¸Ã·½·¨ÓÃÓÚ¼ì²éÖ¸¶¨ÎļþÊÇ·ñ´æÔÚ
function fileexits(string) as boolean
string Ö¸¶¨ËùÒª²éÕÒµÄÎļþ·¾¶£¬Èç¹û¸ÃÎļþ´æÔÚ£¬·µ»ØÖµÎªtrue£¬·ñÔòΪfalse
(6)getextension·½·¨
¸Ã·½·¨ÓÃÓڵõ½ÎļþµÄÀ©Õ¹Ãû
function getextension(string) as string
Èç¹ûÖ¸¶¨µÄÎļþÓÐÀ©Õ¹Ãû£¬Ôò·µ»ØÀ©Õ¹Ãû×Ö·û´®£¬¸Ã×Ö·û´®Ò²°üº¬"."
Èç¹ûÖ¸¶¨µÄÎļþ²»°üº¬ÓÐÀ©Õ¹Ãû£¬Èçstring²ÎÊýÖ¸¶¨µÄÊÇij¸öÎļþ¼ÐµÄ·¾¶£¬Ôò·µ»Øempty
(7)move·½·¨
¸Ã·½·¨ÓÃÓÚ°ÑÒ»¸öÒѾ´æÔÚµÄÎļþÒÆ¶¯µ½Ò»¸öеÄÎļþ¼ÐÏ¡£
sub move(source,destination)
source Ö¸¶¨Ô´ÎļþµÄ·¾¶£¬destinationÖ¸¶¨Ä¿µÄÎļþµÄ·¾¶£¬ºÍcopy·½·¨²»Í¬µÄÊÇʹÓÃmove·½·¨ºóÔ´Îļþ±»É¾³ýÁË¡£
(8)open·½·¨
function open(filename,filemode,fileaccess) as filestream
¸Ã·½·¨·µ»ØµÄÊÇÎļþ²Ù×÷ͨµÀ¶ÔÏófilestream¡£
filemodeºÍfileaccessÔÚsystem.ioÃû×Ö¿Õ¼äÀï¸÷×Ô¶¨ÒåÁËÒ»×éö¾Ù³£Á¿£¬ÓÃÓÚÖ¸¶¨Îļþ²Ù×÷ģʽºÍ²Ù×÷ȨÏÞ¡£
filemode.append ÒÔ×·¼ÓµÄ·½Ê½´ò¿ªÎļþ£¬»òÕßÒÔ×·¼ÓµÄ·½Ê½´´½¨Ò»¸öеÄÎļþ¡£Ê¹ÓÃÕâÖÖģʽ²Ù×÷Îļþʱ£¬±ØÐëºÍfileaccess.writeÒ»ÆðʹÓ㬾ÍÊÇ˵±ØÐëÓÐдÈëȨÏÞ
filemode.create ´´½¨Ò»¸öÐÂÎļþ£¬Èç¹û´æÔÚͬÃûµÄÎļþ£¬½«¸²¸ÇÔÎļþ
filemode.createnew ´´½¨Ò»¸öÐÂÎļþ£¬Èç¹ûÓÐͬÃûÎļþ£¬´ò¿ªÎļþ³ö´í
filemode.open ´ò¿ªÒ»¸öÒѾ´æÔÚµÄÎļþ
filemode.openorcreate ´ò¿ªÒ»¸öÒѾ´æÔÚÎļþ£¬Èç¹û¸ÃÎļþ²»´æÔÚÔò´´½¨Ò»¸öÐÂÎļþ¡£
filemode.truncate µ±Îļþ´ò¿ªÊ±Çå¿ÕÎļþµÄËùÓÐÄÚÈÝ£¬Èç¹ûʹÓÃÕâ¸öÊôÐÔ¶ÔÎļþÖÁÉÙÒªÓÐдÈëµÄȨÏÞ
fileaccess.read ´ò¿ªµÄÎļþÖ»ÓжÁÈ¡µÄȨÏÞ
fileaccess.write ´ò¿ªµÄÎļþÖ»ÓÐдÈëµÄȨÏÞ
fileaccess.readwrite ´ò¿ªµÄÎļþ¼È¿ÉÒÔдÈëÒ²¿ÉÒÔ¶ÁÈ¡
(9)opentext·½·¨
¸Ã·½·¨ÓÃÀ´´´½¨Ò»¸östreamreader¶ÔÏó²¢¶ÔÒѾ´æÔÚµÄÎļþ½øÐжÁÈ¡²Ù×÷¡£
function opentext(string) as streamreader
»òÕßfunction opentext() as streamreader
ºÍopen·½·¨²»Ò»ÑùµÄÊÇ£¬opentext·µ»ØµÄÊÇstreamreader¶ÔÏ󣬴˶ÔÏóÓÃÓÚÖ´ÐжÔÎļþµÄ¶Á²Ù×÷.

