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)
'Write a row.
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 "create directory:" & 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 rootpath = @ "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 ();
}
%>
Summary: ASP and ASP.. Net can both create folders and files. asp uses the FSO component, while ASP. net is a built-in class library, so when ASP does not support FSO, the aboveCodeIt won't work, and ASP. NET won't. However, ASP. NET requires sufficient permissions, and ASP seems to have such vulnerabilities.