File Path Help

CoachBarker

Well-known member
Joined
Jul 26, 2007
Messages
133
Programming Experience
1-3
To create a folder I do this;

VB.NET:
 Private Sub btnCreateFolder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreateFolder.Click
        Try
            ' check to see if the Folder for the entity class exists
            ' if it does not, create the folder
            If Directory.Exists(SelectedDatabase & "\cls" & selectedTable) = False Then
                Directory.CreateDirectory("C:\Documents and Settings\barker44\Desktop\EntityClassGenerator\EntityClassGenerator\EntityClasses")
            End If
        Catch ex As Exception
            MessageBox.Show("Error in frmEntityCLassGenerator, btnCreateFolder: Create folder" & ex.Message)
        End Try
    End Sub

but it gives me the folder here
Folders.JPG
what I would is the folder to be created here

I assume there is a way to write the path that will access the current project and create the folder where Iwant it.
FolderView.JPG
Any help?
Thanks
CoachBarker
 
I don't see the difference between the two pictures. One is just added to the project and the other isn't.

To create a folder where the current executing .exe is, just put the folder name with no path and it should create it in the same directory as the .exe (if that is what you are going for, your explanation is a little confusing to me).
 
The first one I added using the code I provided, the second was added by right clicking EntityClassGenerator, clicking add and then clicking New Folder. I would like to be able to create the new folder following that logic.

If that makes any more sense

Thanks
CoachBarker
 
This code does what I want

VB.NET:
Directory.CreateDirectory(My.Application.Info.DirectoryPath & "\EntityClasses")

Do you know if there is any way to set the property in code to "Include in project"?
 
This code does what I want

VB.NET:
Directory.CreateDirectory(My.Application.Info.DirectoryPath & "\EntityClasses")

Do you know if there is any way to set the property in code to "Include in project"?

Hint: When the program is run, what project will it be adding it to?
 
It will be adding it to the current Project.

Let me explain a little. Most applications I write are 3/4 tier architecture. So what I did was create an application that would create the entity class for the project based on the data base/tables being used for the application. So when creating a new project, I can just add this small application(form) to the new project and run it and it will auto generate my entity classes, modules and data access classes(all generic). Unfortunately forms I will still have to do by hand.
 
Okay, that makes more sense. Before that explanation I was thinking of it as a user application.

The only way that I know how to include something in the project is to do it via the IDE. So, to do it in code you would have to open the .vbproj file as a text file and add that folder to the project manually by editing this file. Of course, I don't think you would be able to do this since you will have the project opened already. Eithe way it would be messy.

Maybe someone else has another way, but I can't think of it.
 
Well for now I will just have to right click on the generated folders and click on add to project. Thanks for your inout.
 
Back
Top