Use ASP and ASP. NET to create folders and files.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.