Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create 2 folders on the fly 1

Status
Not open for further replies.

JohannIcon

Programmer
Sep 3, 2002
440
MT
Is it possible to create 2 folders on the server on the fly? My problem is that I am trying to create 2 folders on the server, with the current year, ie 2002 and current month, ie Nov. So /2002/Nov. The problem is that if folder 2002 already exists, everything works and Nov is created, however, if 2002 does not exist, which in real circumstances, it won't, the asp is telling me that "Path not found"

Here is the code:-

dim fs,Folder
set fs=createobject("scripting.filesystemobject")

Folder=(Server.MapPath("/Johann"+LinkFolder1))

If NOT fs.FolderExists(Folder) then
fs.CreateFolder(Folder)
er = 1
end if
Where LinkFolder1 is currentYear/CurrentMonth

How can I create two folders on the fly?

 
You're just going to have to check to see if the year folder exists first. If it doesn't create it and then create the month folder. If it does exist then just create the month folder. Mighty :)
 
And can I do it in the same asp or I have to create 2 asp's?
 
You can do it all in the one program. Something like the following:

Dim fs, folder, yearFolder, monthFolder

yearFolder = Server.MapPath("/Johann/" & year(date))
monthFolder = Server.MapPath("/Johann/" & year(date) & "/" & monthname(month(date), true))

set fs=Server.Createobject("scripting.filesystemobject")

if fs.FolderExists(yearFolder) then
set folder = fs.CreateFolder(monthFolder)
else
set folder = fs.CreateFolder(yearFolder)
set folder = fs.CreateFolder(monthFolder)
end if Mighty :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top