问题描述:
怎样把信息写入WPL文件?wpl文件是Media player的播放列表文件
<?wpl version="1.0"?>
<*** il>
<head>
<meta name=Generator content="Microsoft Windows Media Player -- 10.0.0.3802"/>
<author/>
<title>播放列表</title>
</head>
<body>
<seq>
<Media src=voovoo/uploadfiles/musics/yqnyh.mp3 />
<Media src=goo365/music/tayidinghenain.mp3 />
<Media src=ahradio/fm1055/down/gh_rahzxsy.mp3 />
<Media src=imop-multimedia.mop/14/07/05/29_***********.mp3 />
<Media src=cdn.adu/ting_cococ__2005/0/1/9388/060801/wlx/1.wma />
<Media src=data1.13139/post/2006/08/04/482.mp3 />
<Media src=bbs.zjcxnews/UploadFile/2006-10/200610271453468720.mp3 />
<Media src=61.139.44.142/wangwenquan/uploadfile/200662880433.mp3 />
</seq>
</body>
</ *** il>
上面就是一个WPL文件,我想把从后台调出来的歌曲地址添加到这个文件里面,请高手帮忙
解析:
set fso=server.createobject("Scripting.FileSystemObject") '创建FSO对象
Set textstr = fso.CreateTextFile("abc.wpl", True, False) '方法二 创建一个文本文件
textstr.WriteLine ("<Media src=cdn.adu/ting_cococ__2005/0/1/9388/060801/wlx/1.wma />
") '向创建的文本文件中写入一行文本
textstr.Close '刷新缓冲区并关闭文件
Set fso = Nothing
假设你在一个表单中收集了一些用户信息,这里是一个简单表单HTML代码:<html>
<body>
<form action="formhandler.asp" method="post">
<input type="text" size="10" name="username">
<input type="text" size="10" name="homepage">
<input type="text" size="10" name="Email">
</form>
</body>
</html>
再看看formhandler.asp中处理表单的代码:
<%
Get form info
strName = Request.Form("username")
strHomePage = Request.Form("homepage")
strEmail = Request.Form("Email")
create the fso object
Set fso = Server.CreateObject("Scripting.FileSystemObject")
迄今为止,还没有新鲜的东西,无非是获取表单域的值并且赋值到变量。下面出现了有趣的部分 - 写文件:
path = "c:empest.txt"
ForReading = 1, ForWriting = 2, ForAppending = 3
open the file
set file = fso.opentextfile(path, ForAppending, TRUE)
write the info to the file
file.write(strName) &vbcrlf
file.write(strHomePage) &vbcrlf
file.write(strEmail) &vbcrlf
close and clean up
file.close
set file = nothing
set fso = nothing
回想一下,OpenTextFile方法返回一个TextStream对象,它是FSO模型中的另外一个对象。TextStream对象揭示了 *** 作文件内容的方法,比如写、读一行、跳过一行。VB常量vbcrlf产生一个换行符。
在OpentextFile的命令参数中定义了TRUE,这就告诉了系统,如果文件不存在,就创建它。如果文件不存在,并且没有定义TRUE参数,就会出错。
现在转到目录c: emp,打开test.txt,你可以看到如下的信息:
Users name
Users home page
Users email
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)