Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

vb.net: create incrementally named directories

Options
  • 16-03-2007 12:51am
    #1
    Registered Users Posts: 1,002 ✭✭✭


    I have a web app where a user can upload a file to a directory0.
    When that directory0 hits 100 files, another directory is created, named directory1 and the files get uploaded to directory1 and continues for directory2...and so on....
    It works except for naming of the new directory and setting it as the current directory to upload to.

    The problem is that I don't quite know what it is I am trying to do, is it a loop of some kind?

    The part I can't get working is the naming of the next directory.

    So far I have something like this:
    Dim a as integer = 0
    Dim DirectoryLocation As String = "UploadedFiles/directory" & a & "/"
    
    To create a new directory
    Dim DirectoryLocationNew As String = "UploadedFiles/directory" & a + 1 & "/"
    Directory.CreateDirectory(Server.MapPath(DirectoryLocationNew))
    
    Above works for directory1, not for directory2, directory3, etc

    If I new what I was trying to do.... :o txs


Comments

  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    It looks like you're not incrementing a. In your code above you'll only be able to create directory0 and directory1. You'll probably want to declare a at module level and then do something like the following:
    Dim DirectoryLocation As String = "UploadedFiles/directory" & a & "/"
    
    [b]a = a + 1[/b]
    
    Dim DirectoryLocationNew As String = "UploadedFiles/directory" & a & "/"
    Directory.CreateDirectory(Server.MapPath(DirectoryLocationNew))
    

    Initialising a to equal the number of directories is something else you'll have to think about.


Advertisement