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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

vb.net: create incrementally named directories

  • 15-03-2007 11:51pm
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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