Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 Create folder in asp

views
     
TSsaimatkong
post Mar 3 2006, 02:17 PM, updated 20y ago

Newbie
******
Senior Member
1,938 posts

Joined: Jan 2003
From: http://blog.saimatkong.com



ok i able to create folder in asp.
but i need you guys to enlighten me on this.

the folder structure is like this.
Saimatkong >> Saimatkong Sub >> Saimatkong Sub Sub

Saimatkong Sub Sub is a folder in Saimatkong Sub
and Saimatkong Sub is a folder in Saimatkong.

so i need the algo to create all the sub sub folder in the parent folder.

give info.

Folder Name eg. >> Saimatkong Sub Sub
Parent Folder Name >> Saimatkong Sub
Path >> Saimatkong > Saimatkong Sub

with the provided info how could i do some looping to create all the sub sub folder?
i need the algo. i can think of it. blush.gif
thanks.

shinchan^^
post Mar 3 2006, 03:30 PM

K66
*********
All Stars
21,256 posts

Joined: Jan 2003
From: Pekopon


i m confused with ur folder name doh.gif doh.gif
TSsaimatkong
post Mar 3 2006, 03:37 PM

Newbie
******
Senior Member
1,938 posts

Joined: Jan 2003
From: http://blog.saimatkong.com



aiks sorry.
basically, (saimatkong sub = saimatkong subfolder) inside saimatkong.
and (saimatkong sub sub = saimatkong subfolder subfolder) inside saimatkong subfolder.

got the structure ?
hehe laugh.gif
eggy
post Mar 3 2006, 04:50 PM

Question authority; but, raise your hand 1st
******
Senior Member
1,761 posts

Joined: Feb 2006
From: Kajang | Shah Alam Mood: Confused -_-"



QUOTE(saimatkong @ Mar 3 2006, 03:37 PM)
aiks sorry.
basically, (saimatkong sub = saimatkong subfolder) inside saimatkong.
and (saimatkong sub sub = saimatkong subfolder subfolder) inside saimatkong subfolder.

got the structure ?
hehe laugh.gif
*
Saimatkong ( Main Folder )
-->Saimatkong ( Saimatkong subfolder )
------>Saimatkong ( Saimatkong subfolder subfolder)

thumbup.gif

This post has been edited by eggy: Mar 3 2006, 04:50 PM
nxfx
post Mar 3 2006, 04:52 PM

Enthusiast
*****
Senior Member
979 posts

Joined: Jan 2003


Didnt test but hope it helps..

Dim foldername
Dim deep As
Dim str As

str = "c:"
foldername = "\saimatkong"
deep = 2

For i = 0 To deep
str = str & foldername
set f=fs.CreateFolder(str)
next
TSsaimatkong
post Mar 3 2006, 05:03 PM

Newbie
******
Senior Member
1,938 posts

Joined: Jan 2003
From: http://blog.saimatkong.com



QUOTE(eggy @ Mar 3 2006, 04:50 PM)
Saimatkong ( Main Folder )
-->Saimatkong ( Saimatkong subfolder )
------>Saimatkong ( Saimatkong subfolder subfolder)

thumbup.gif
*
thanks but wat i mean it should be
Saimatkong ( Main Folder )
-->Saimatkong sub( Saimatkong subfolder )
------>Saimatkong sub sub( Saimatkong subfolder subfolder)

for clearer image of the folder structure. smile.gif
TSsaimatkong
post Mar 3 2006, 05:08 PM

Newbie
******
Senior Member
1,938 posts

Joined: Jan 2003
From: http://blog.saimatkong.com



QUOTE(nxfx @ Mar 3 2006, 04:52 PM)
Didnt test but hope it helps..

Dim foldername
Dim deep As
Dim str As

str = "c:"
foldername = "\saimatkong"
deep = 2

For i = 0 To deep
    str = str & foldername
    set f=fs.CreateFolder(str)
next
*
i think u misun my concept.
the concept is like this.

i given the folder name and deep above is just as an example.
but the name and folder level is dynamic base on the info that i get.

Folder Name. Folder Parent. Folder Path.

Folder Name eg. (saimatkong sub sub)
Folder Parent eg. (saimatkong sub)
Folder Path eg. (saimatkong > saimatkong sub > saimatkong sub sub

ps. Folder Path is the full path to the current folder.
hope i have gotten the image clear. smile.gif
thanks
nxfx
post Mar 4 2006, 08:49 AM

Enthusiast
*****
Senior Member
979 posts

Joined: Jan 2003


Do you mean something like this,
C:\saimatkong\saimatkong sub\saimatkong sub sub ?
lighching
post Mar 4 2006, 12:39 PM

Regular
******
Senior Member
1,348 posts

Joined: Nov 2004
From: Red Planet. NeverLand Area 7
use the System.Diagnostics.Process function, use the mkdir.exe
CODE

mkdir "c:\Saimatkong\Saimatkong Sub\Saimatkong Sub Sub"


or use the directoryInfo function to create new folder.
TSsaimatkong
post Mar 4 2006, 08:29 PM

Newbie
******
Senior Member
1,938 posts

Joined: Jan 2003
From: http://blog.saimatkong.com



QUOTE(nxfx @ Mar 4 2006, 08:49 AM)
Do you mean something like this,
C:\saimatkong\saimatkong sub\saimatkong sub sub ?
*
yup. like this.
but it's depends on the info and it's dynamic.
not necessary saimatkong or not necessary how many folder or sub folder in a folder. the part is kinda hard to think
TSsaimatkong
post Mar 4 2006, 08:30 PM

Newbie
******
Senior Member
1,938 posts

Joined: Jan 2003
From: http://blog.saimatkong.com



QUOTE(lighching @ Mar 4 2006, 12:39 PM)
use the System.Diagnostics.Process function, use the mkdir.exe
CODE

mkdir "c:\Saimatkong\Saimatkong Sub\Saimatkong Sub Sub"


or use the directoryInfo function to create new folder.
*
i'm able to create folder.
just tat i need the algo to create the folder structure. blink.gif
nxfx
post Mar 6 2006, 12:17 PM

Enthusiast
*****
Senior Member
979 posts

Joined: Jan 2003


Dim foldername
Dim deep As Integer
Dim str As String
Dim str2 As String

str = "c:"
str2 = " sub"
foldername = "\saimatkong"
deep = 3

For i = 0 To deep

If i > 0 Then
str = str & foldername & str2
str2 = str2 & str2
Else
str = str & foldername
End If

Next

Try running it and see how it goes. You can pass the drive to str, the sub sub tinggie to str2 and the folder name to foldername. It will generate directory according to the deep.
TSsaimatkong
post Mar 6 2006, 01:44 PM

Newbie
******
Senior Member
1,938 posts

Joined: Jan 2003
From: http://blog.saimatkong.com



QUOTE(nxfx @ Mar 6 2006, 12:17 PM)
Dim foldername
Dim deep As Integer
Dim str As String
Dim str2 As String

str = "c:"
str2 = " sub"
foldername = "\saimatkong"
deep = 3

For i = 0 To deep
 
    If i > 0 Then
        str = str & foldername & str2
        str2 = str2 & str2
    Else
      str = str & foldername
    End If
   
Next

Try running it and see how it goes. You can pass the drive to str, the sub sub tinggie to str2 and the folder name to foldername. It will generate directory according to the deep.
*
i think you misun me.
the deep and the folder name is dynamic so it can't be generate this way wor.
nxfx
post Mar 6 2006, 02:07 PM

Enthusiast
*****
Senior Member
979 posts

Joined: Jan 2003


Why not? You can change the deep and folder name anytime you want to create a new folder. for example you get the info for folder name "Ali' and the depth = 1 , then you just pass "Ali" to foldername and deep =1.
shinchan^^
post Mar 6 2006, 02:43 PM

K66
*********
All Stars
21,256 posts

Joined: Jan 2003
From: Pekopon


to delete files
use this one

Option Compare Database
Option Explicit

Public Function DeleteAllFiles(ByVal FolderSpec As String) As Boolean

'Deletes all files in folder specified
'by parameter FolderSpec. Does not delete
'subfolders or files within subfolders

'Returns True if sucessful, false otherwise

'Requires a reference the Microsoft Scripting Runtime

'EXAMPLE: DeleteAllFiles "C:\Test"

Dim oFs As New FileSystemObject
Dim oFolder As Folder
Dim oFile As File


If oFs.FolderExists(FolderSpec) Then
Set oFolder = oFs.GetFolder(FolderSpec)
On Error Resume Next
For Each oFile In oFolder.Files
oFile.Delete True 'setting force to true
'deletes read-only file
Next
DeleteAllFiles = oFolder.Files.Count = 0
End If

End Function




haha currently i m need this
TSsaimatkong
post Mar 6 2006, 04:54 PM

Newbie
******
Senior Member
1,938 posts

Joined: Jan 2003
From: http://blog.saimatkong.com



QUOTE(nxfx @ Mar 6 2006, 02:07 PM)
Why not? You can change the deep and folder name anytime you want to create a new folder. for example you get the info for folder name "Ali' and the depth = 1 , then you just pass "Ali" to foldername and deep =1.
*
but how would u pass it dynamically ?
anyway i have figure it out how to create the folder sturucture.
thanks
TSsaimatkong
post Mar 6 2006, 04:56 PM

Newbie
******
Senior Member
1,938 posts

Joined: Jan 2003
From: http://blog.saimatkong.com



QUOTE(shinchan^^ @ Mar 6 2006, 02:43 PM)
to delete files
use this one

Option Compare Database
Option Explicit

Public Function DeleteAllFiles(ByVal FolderSpec As String) As Boolean

'Deletes all files in folder specified
'by parameter FolderSpec.  Does not delete
'subfolders or files within subfolders

'Returns True if sucessful, false otherwise

'Requires a reference the Microsoft Scripting Runtime

'EXAMPLE: DeleteAllFiles "C:\Test"

Dim oFs As New FileSystemObject
Dim oFolder As Folder
Dim oFile As File
If oFs.FolderExists(FolderSpec) Then
    Set oFolder = oFs.GetFolder(FolderSpec)
    On Error Resume Next
    For Each oFile In oFolder.Files
        oFile.Delete True 'setting force to true
                        'deletes read-only file
    Next
    DeleteAllFiles = oFolder.Files.Count = 0
End If

End Function
haha currently i m need this
*
ahah good good thumbup.gif


 

Change to:
| Lo-Fi Version
0.0170sec    0.52    5 queries    GZIP Disabled
Time is now: 25th December 2025 - 02:25 AM