I need to create a new folder every time the upload folder has 10 files uploaded to it. So when folder1 has 10 files, folder2 is created and becomes the upload folder, and when it has 10 files uploaded to it folder3 is created and so on.....
Problem is that my code creates all the next folders all at once. I need it to create the next folder when it is required. i.e. when the previous folder has reached 10 files.
If anyone can explain where I am going wrong I would appreciate it. txs.
-
'Get number of files in current dir
-
Dim CurrentDir() As String = Directory.GetFiles(Server.MapPath("UploadedPictures/subfolder1/"))
-
'If current directory has 10 files, then create new directory, else save it to current dir
-
If CurrentDir.Length > 10 Then
-
Dim a As Integer
-
For a = 1 To 10 (or infinite)
-
Dim dir As New DirectoryInfo(Server.MapPath("UploadedPicturesThb/" & a & "subFolder" & "/"))
-
If dir.Exists = True Then
-
Dim fi() As FileInfo = dir.GetFiles("*.jpg")
-
If fi.Length <= 10 Then
-
' save jpg to folder
-
End If
-
Else
-
di.Create()
-
' save jpg to folder
-
End If
-
Next
-
Else
-
' save jpg to folder
-
End If
-
'Need to get name of current upload directory so that I can add it to the database????
-