Kevin
Kevin

Reputation: 205

VB.NET Project Folder Question

So if I am working on a project in VB.net (really any visual studio project), I am able to create folders. My project is getting rather unweildy (over 30 classes) and I think it would be beneficial to store for example data structure classes in a folder "ds" and user controls in a folder "uc". Is this OK? Will it affect the way I reference the classes? Are the folders simply for my own use and structure or do they actually have some kind of impact on my project as a whole?

PS in case you are confused, I am referring to the structure shown in the "Solution Explorer". Sorry if this is a dumb question or not clear, but I have never worked on a large project like this before.

Upvotes: 5

Views: 1890

Answers (4)

orkutWasNotSoBad
orkutWasNotSoBad

Reputation: 648

There's no such thing as dumb questions. ;) You can do this, but do yourself a favor and keep your namespaces the same as your folder hierarchy or you can end up with a bird's nest pretty quickly. For example, if the project's default namespace is MyProject and the folder is Dc, those classes should be in

Namespace MyProject.Dc

Edit: Just wrap your classes to mirror your folder structure like:

Namespace MyProject.Ds
    Module MyModule

        Sub Main()
            'do stuff here
        End Sub

    End Module
End Namespace

Upvotes: 5

Sabitha
Sabitha

Reputation: 243

Adding a new Folder shouldn't change anything in your project, if you are careful about the namespaces they are in and also being careful while referring to Class files using their path.

Upvotes: 0

Taryn
Taryn

Reputation: 247830

You can use folders for everything. I do it all the time, you just need to include the folders name when accessing it.

enter image description here

So if I wanted to call something in the Exceptions folder, I would use Exceptions.DialogExceptionEdit, etc.

Upvotes: 2

DaveShaw
DaveShaw

Reputation: 52798

Adding the folders will default the namespace of any newly added files into those folders to include the folder name. For example MyApp.UC or MyApp.DS.

Creating a folder and moving your user controls, data structures etc. shouldn't be a problem.

You can always test this on a new Test Project - that's my usual way :)

Upvotes: 4

Related Questions