Add to Favorites    Make Home Page 22029 Online  
 Language Categories  
 Our Services  

Home » ASP Home » Files Home » Delete Files

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title Delete Files
Description Enables users to list and delete files
Category ASP » Files
Hits 364606
Code Select and Copy the Code
'************************************** ' Name: DeleteFiles+ ' Description:' 'Based on the original DeleteFiles ' by Jason Buck, this ASP page 'allows the user to list and delete 'files in the directory in which it 'resides. ' 'The modifications include 'an "are you sure" screen, 'displaying an image file, 'hiding this script itself 'so it won't be listed and 'css buttons. ' ' Inputs:' 'QueryStrings are still passed to 'dispaly the screens and delete 'the files. ' 'file=file or file=image 'Distingushes between images 'and other file types ' 'delete=show,delete=sure, 'or delete=yes 'will show a file, display 'the are you sure screen and 'lastly call the delete function ' 'FN=passes which file will be 'deleted ' ' Returns:' 'list of files in the directory, 'display of an image/file name 'are you sure screen 'confirmation of deletion screen ' ' Side Effects:' 'Simple... the file is GONE and 'cannot be undone. ' <HTML> <HEAD> <TITLE>Delete a File</TITLE> <!-- This style creates the buttons For the script --> <style> <!-- body, td, li, p, table, Input { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; } a:hover.Button { color: #FF0000; background: #CCCCCC; } A.Button { Text-decoration: none; color: #000000; background: #CCCCCC; } .Button { Text-align: center; Text-decoration: none; color: #000000; background: #CCCCCC; border-top: 2px solid #EEEEEE; border-Left: 2px solid #EEEEEE; border-Right: 2px solid #999999; border-bottom: 2px solid #999999; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; padding-Left: 4; padding-Right: 4; padding-top: 2; padding-bottom: 2; } --> </style> </HEAD> <BODY> <P align="center"><FONT size="6" color="#FF0000">File Deletion</FONT></P> <% strdelete = Request.QueryString("delete") strFN = Request.QueryString("FN") strFT = Request.QueryString("file") 'display the SHOW-ME-THE-FILE screen If strdelete = "Show" Then If strFT = "image" Then Response.Write "<P align=center> <Img width=320 height=240 src=" & strFN & "><BR><BR>" Response.Write "<A class=button href=default.asp?file=image&delete=Sure&FN=" & strFN & ">Delete?</A> " Response.Write "<A class=button href=default.asp>List Files</A> <BR><BR></P>" Else Response.Write "<P align=center><FONT color=Blue size=5>" & strFN & "</FONT><BR><BR>" Response.Write "<A class=button href=default.asp?file=file&delete=Sure&FN=" & strFN & ">Delete?</A> " Response.Write "<A class=button href=default.asp>List Files</A> <BR><BR></P>" End If Response.End End If 'display the ARE-YOU-SURE screen If strdelete = "Sure" Then If strFT = "image" Then Response.Write "<P align=center> <Img width=320 height=240 src=" & strFN & "><BR><BR>" Response.Write "<FONT color=Red size=5>Are You Sure You Want To Delete This File?</FONT><BR>" Response.Write "<A class=button href=default.asp?delete=Yes&FN=" & strFN & ">Yes, Delete It.</A> " Response.Write "<A class=button href=default.asp>NO, Do Not Delete It!</A> <BR><BR></P>" Else Response.Write "<P align=center><FONT color=Blue size=5>" & strFN & "</FONT><BR><BR>" Response.Write "<FONT color=Red size=5>Are You Sure You Want To Delete This File?</FONT><BR>" Response.Write "<A class=button href=default.asp?delete=Yes&FN=" & strFN & ">Yes, Delete It.</A> " Response.Write "<A class=button href=default.asp>NO, Do Not Delete It!</A> <BR><BR></P>" End If Response.End End If 'call the delete function If strdelete = "Yes" Then Call functionDF() End If 'the delete function Sub functionDF() Dim fso, f1 Set fso = CreateObject("Scripting.FileSystemObject") Set f1 = fso.GetFile(Server.MapPath(strFN)) f1.Delete Response.Write "<P align=center>File <B>" & strFN & "</B> Deleted! <BR><BR>" Response.Write "<A class=button href=default.asp>Return To List</A><BR></P>" Response.End End Sub 'view files in this directory dirtowalk = "./" 'display the files Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.GetFolder(Server.MapPath(dirtowalk)) Set fc = f.Files Response.Write "<HR>" Response.Write "<P><FONT size=5 >File List</FONT></P> " For Each tobdel In fc 'dont display this page If tobdel.name = "default.asp" Then Response.Write "" 'is the file an image? ElseIf Right(tobdel.name, 4) = ".jpg" Then Response.Write "<A class=button href=default.asp?file=image&delete=Show&FN=" & tobdel.name & "><I><B>View</B></I></A> " Response.Write "<A class=button href=default.asp?file=image&delete=Sure&FN=" & tobdel.name & "><I><B>Del</B></I></A> " & tobdel.name & "<BR><BR>" ElseIf Right(tobdel.name, 4) = ".gif" Then Response.Write "<A class=button href=default.asp?file=image&delete=Show&FN=" & tobdel.name & "><I><B>View</B></I></A> " Response.Write "<A class=button href=default.asp?file=image&delete=Sure&FN=" & tobdel.name & "><I><B>Del</B></I></A> " & tobdel.name & "<BR><BR>" ElseIf Right(tobdel.name, 4) = "jpeg" Then Response.Write "<A class=button href=default.asp?file=image&delete=Show&FN=" & tobdel.name & "><I><B>View</B></I></A> " Response.Write "<A class=button href=default.asp?file=image&delete=Sure&FN=" & tobdel.name & "><I><B>Del</B></I></A> " & tobdel.name & "<BR><BR>" '...or another file type Else Response.Write "<A class=button href=default.asp?file=file&delete=Show&FN=" & tobdel.name & "><I><B>View</B></I></A> " Response.Write "<A class=button href=default.asp?file=file&delete=Sure&FN=" & tobdel.name & "><I><B>Del</B></I></A> " & tobdel.name & "<BR><BR>" End If Next %> </P> </BODY> </HTML>

Related Source Codes

Script Name Author
ııııııııııııııııııııı VyomWorld
Resistor color code reader A.Chermarajan.
Telephone Directory dhivya
card swapping game (Mini Project) nityanand
simple hangman-pascalsource Seabert
college dirtectory (Mini Project) msridhar
Poll Application John van Meter
ASP Daily Hit Counter. Tejaskumar Gandhi
To avoid null in asp environment using sql Sami
Maklumbalas webmaster
poll John van Meter
EasyASP Template Engine. TjoekBezoer
Basic Calculator using HTML & Javascript. Patrick M. D Souza
What servers support ASP ? VyomWorld
What is ASP? VyomWorld

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=342


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review