123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home

Source Codes

Engineering Colleges

BE Students

Training  Reports (updated)

Seminar Reports (updated

Placement Papers (updated)

Forums

   Computer Science / IT

   Electronics

   Electrical

   Mechanical

   Chemical

   Civil

   CAT / MBA

   GMAT / Foreign MBA

Latest Jobs

Engineering Jobs / Technical Jobs

Management Jobs

Sitemap

About-Us

Terms of use

Displaying  Source Code(s)  
 

 
Delete Files

--------------------------------------------------------------------------------

Description : Enables users to list and delete files

'**************************************
' 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>

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved copyright 123ENG