国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

使用ASP和ASP.NET來創(chuàng)建文件夾和文件。

2024-07-10 13:06:26
字體:
供稿:網(wǎng)友

asp:

<%
sub writefile(file)
 response.write "file:"+file
 dim fso, tf
 set fso = createobject("scripting.filesystemobject")
 set tf = fso.createtextfile(file, true)
 tf.writeline("testing 1, 2, 3.")
 tf.writeblanklines(3)
 ' 寫一行。
 tf.write ("this is a test.")
 tf.close
 set tf = nothing
 set fso = nothing
end sub

sub createfolder(path)
 dim fso,fldr
 set fso = createobject("scripting.filesystemobject")
 set fldr = fso.createfolder(path)
 response.write "創(chuàng)建目錄:"&fldr.name
 set fldr = nothing
 set fso = nothing
end sub

path = request.querystring("path")
filename = request.querystring("filename")
file = path + "/" + filename
if path<>"" or filename<>"" then
createfolder(path)
writefile(file)
end if
%>

asp.net

<%@ page language="c#" debug="true" contenttype="text/html" responseencoding="gb2312" %>
<%@ import namespace="system.diagnostics" %>
<%@ import namespace="system.io" %>

<%
string filestr=request.params["file"]+"";
filestr=filestr.trim();
if(filestr==""){
 response.write("file is null<p>");
 return;
}

response.write(filestr+"<p>");
string [email protected]"e:/test/";
string dir=filestr+"dir";
filestr=rootpath+filestr;
response.flush();

if(directory.exists(rootpath+dir)) response.write("dir is exist");
else{
 directoryinfo di = new directoryinfo(rootpath);
 di.createsubdirectory(dir);
 //response.write("create dir:"+directory.createdirectory(dir));
}

response.write("start write file str<p>");
response.flush();

using (streamwriter sw = new streamwriter(filestr))
{
 string line="test ming";
 sw.write(line);
  sw.close();
 }
%>

小結(jié):asp和asp.net都可以創(chuàng)建文件夾和文件,asp是用fso組件,而asp.net則是有自帶的類庫,所以當(dāng)asp不支持fso時(shí),以上的代碼就不能工作了,而asp.net就不會(huì)有這種問題。但是asp.net操作需要足夠的權(quán)限,而asp好像就有這種漏洞似的。   


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 逊克县| 太谷县| 麟游县| 铅山县| 喀喇沁旗| 辽源市| 且末县| 勐海县| 朝阳区| 建始县| 盱眙县| 富源县| 昌都县| 辽宁省| 合川市| 新巴尔虎左旗| 定西市| 东台市| 乌拉特中旗| 介休市| 浦江县| 定襄县| 新余市| 连江县| 南开区| 桐梓县| 大城县| 汉中市| 竹山县| 镇安县| 弋阳县| 密云县| 崇州市| 吴忠市| 桐庐县| 民乐县| 丹阳市| 涿鹿县| 安顺市| 隆尧县| 区。|