techpreparation-homepage

Home  Interview Questions  Aptitude Questions  Tutorials  Placement Papers  Search  Resume Guide  Soft Skills  Video  Forum  Blog


Technical Interview Questions

Visual Basic Interview Question
.NET Web Interview Questions
.NET Interview Questions
C# Interview Questions
                              .........More

Source Codes
Asp .NET Source Codes
Asp VB Script Source Codes
                              .........More

Soft Skills
Communication Skills
Leadership Skills
                              .........More

Subscribe to our Newsletters
Name:
Email:

 

 

  

Asp/VB Script Source Codes

Directory Listing

Get the filenames in a directory

Replace "directoryname" with your directory name.
Note : Replace 'directoryname' with the name od directory you wish to read
In case of NT the directory mush have read permission for being read from anonymous account

<%Set MyDirectory=Server.CreateObject("Scripting.FileSystemObject")
Set MyFiles=MyDirectory.GetFolder(Server.MapPath("directoryname"))
For each filefound in MyFiles.files
Response.write filefound.Name
Next
%>

Attributes of a directory

<%
' Code for setting the target directory 'images'
Set fso = Server.CreateObject ("scripting.filesystemobject")
location = server.mappath("images")
Set folder = fso.GetFolder(location)
%>

Size : <% =folder.size %>
Output : Size : 84 bytes


Created : <% =folder.datecreated %>
Output : Created : 1/23/2000 10:13:13 AM


Modified : <% =folder.datelastmodified %>
Output : Modified : 1/23/2000 10:13:14 AM


Name : <% =folder.name %>
Output : Name : images

Create a directory
Note : You'll need permissions on the parent directory set to allow the IUSR_machinename to create the directory.
This means that the IUSR will need to be given NTFS Change permissions

<%
set fs=createobject("scripting.filesystemobject")
MyFolder=server.mappath("/download/incoming/")

If NOT fs.folderexists(MyFolder) then
fs.createfolder(MyFolder)
End If
' Check if the creation was a success or not
If fs.folderexists(MyFolder) then
Response.write "Success"
Else
Response.write "Failure."
End If
%>

Delete a directory
Note : You'll need permissions on the parent directory set to allow the IUSR_machinename to create the directory.
This means that the IUSR will need to be given NTFS Change permissions

<%
set fs=createobject("scripting.filesystemobject")
MyFolder=server.mappath("/download/incoming/")

set delDir = fs.getfolder(myFolder)
delDir.delete
set delDir = Nothing

'Check if the deletion was a success or Not
If fs.folderexists(myFolder) then
Response.write "Deleted"
Else
Response.write "Error"
End If
%>


<<<----- Return to Asp/VB Script Source Code Questions Page.


Have a Question ? post your questions here. It will be answered as soon as possible.

Check Microsoft .Net Interview Questions for more Microsoft .Net Interview Questions with Answers.

Check .Net Database Interview Questions for more .Net Database Interview Questions with answers

Check Job Interview Questions for more Interview Questions with Answers