在為上海中小企業(yè)建設(shè)網(wǎng)站過程中,發(fā)現(xiàn)客戶需要修改網(wǎng)頁文件,比如首頁數(shù)據(jù),關(guān)于我們等,客戶又沒有FTP帳號(hào),這樣就可以把下面的代碼實(shí)現(xiàn)的功能寫到后臺(tái)當(dāng)中,方便網(wǎng)站管理員或網(wǎng)絡(luò)公司技術(shù)員登陸后臺(tái)直接修改代碼。這樣就省了很多時(shí)間,一些客戶就是改一個(gè)圖片或者文字,很簡單,這個(gè)功能比較實(shí)用。。。。
ASP讀取文件
簡潔版:
CreateObject("Scripting.FileSystemObject").OpenTextfile(Server.MapPath("Muma.txt"),1,False).Readall
完整版:
set fs=server.createobject("scripting.filesystemobject")
file=server.mappath("pic/fuck.txt")
set txt=fs.opentextfile(file,1,true)
if not txt.atendofstream then line=txt.readall 'ReadLine從文件中讀取一行數(shù)據(jù);Read(N)從文件中讀取N個(gè)字節(jié)的數(shù)據(jù);ReadAll讀取文件中的所有數(shù)據(jù)
response.write "
"
ASP寫入/保存文件
簡潔版:
Server.CreateObject("Scripting.FileSystemObject").OpenTextFile(Server.MapPath("test.txt"),2,True).WriteLine Request("TxtData")
完整版:
Set Fs=Server.CreateObject("Scripting.FileSystemObject")
Set File=Fs.OpenTextFile(Server.MapPath("ip.txt"),2,True) '2覆蓋,8追加;True文件不存在則自動(dòng)創(chuàng)建.Flase不自動(dòng)創(chuàng)建
File.Writeline content
File.Close
瑞安網(wǎng)站建設(shè)專業(yè)服務(wù)商--瑞安市聯(lián)創(chuàng)網(wǎng)絡(luò)信息有限公司 電話:13958850180