473,395 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Project management, multiple directories and namespaces

I'm new to C# and am used to Java, where there is a correspondence
between package names and directories. I'm having trouble creating the
same functionality in Visual Studio. In particular, I'm having trouble
compiling such projects.

As an example, suppose I have a project called ConsoleApplication1. It
is stored in a directory called c:\src\ConsoleApplication1. I want to
add a file to this project that is called MyFile.cs and is stored in a
directory called c:\src\ConsoleApplication1\Utils. The source in
MyFile.cs has the following namespace: ConsoleApplication1.Utils.

My problem is accessing a public class declared in MyFile.cs from
ConsoleApplication1.cs. If I try to "Add" MyFile.cs to my project,
Visual Studio has a tendency to copy the file into my current directory.
That is not at all what I want. I want to access the file while it is in
a subdirectory of my main project directory. How do I do this?

I've found something called a References Path in the Properties dialog
for my project, but if it is related to this issue, I don't see how to
use it.

If people feel that all the source code for a C# project should be in
one directory, then please say so. If the solution is to build an
assembly (ie DLL) then please say so, though that is again not at all
what I want to do.

Thank you for your help.

- Charlie
Nov 16 '05 #1
3 2254
Charlie,
That is not at all what I want. I want to access the file while it is in
a subdirectory of my main project directory. How do I do this?


In Solution Explorer, click the Show All Files toolbar button to see
files and directories that aren't included in your project (it should
show the Utils subdirectory and the MyFile.cs file in it). Right-click
MyFile.cs and select Include In Project.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #2
Hello Charlie

All you need to do is to add a folder to your application by the name utils and then add the file MyFile.cs in the utils folder
and then you wil be able to use your public class in a desired manner

Reason
There is a difference between java package and .net namespace , in java, package always maps to directory structure where as a .net namespace may/may not map to a directory structure. If you want your files (cs or any project related files) to be placed in different folders within the appliction folder then just create those folders from within visual studio.net, vs.net will not manage namepaces accordingly but also will make you feel namespaces much like java packages. Important thing is that
creating namespace (like myApplication.Services) will not create directory Services in myApplication, rather it is the other way around

I hope it serves the purpose

best regards
Hammad.Rajjou

----- Charlie Calvert wrote: ----

I'm new to C# and am used to Java, where there is a correspondence
between package names and directories. I'm having trouble creating the
same functionality in Visual Studio. In particular, I'm having trouble
compiling such projects

As an example, suppose I have a project called ConsoleApplication1. It
is stored in a directory called c:\src\ConsoleApplication1. I want to
add a file to this project that is called MyFile.cs and is stored in a
directory called c:\src\ConsoleApplication1\Utils. The source in
MyFile.cs has the following namespace: ConsoleApplication1.Utils

My problem is accessing a public class declared in MyFile.cs from
ConsoleApplication1.cs. If I try to "Add" MyFile.cs to my project,
Visual Studio has a tendency to copy the file into my current directory.
That is not at all what I want. I want to access the file while it is in
a subdirectory of my main project directory. How do I do this

I've found something called a References Path in the Properties dialog
for my project, but if it is related to this issue, I don't see how to
use it

If people feel that all the source code for a C# project should be in
one directory, then please say so. If the solution is to build an
assembly (ie DLL) then please say so, though that is again not at all
what I want to do

Thank you for your help

- Charli

Nov 16 '05 #3
Hammad and Mattias,

Thank you both. You solved my problems. My project had just gotten big
enough so that I had to start organizing it, and you've made it possible
for me to do that.

- Charlie
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: JKop | last post by:
Here's what I know so far: You have a C++ project. You have source files in it. When you go to compile it, first thing the preprocessor sticks the header files into each source file. So now...
1
by: Steven T. Hatton | last post by:
I think Danny was one cup of coffee shy of full consciousness when he wrote this, but the gist of it makes sens to me: "C++ Project Organization Guidelines Last updated May 26, 2005....
10
by: TokiDoki | last post by:
Hello there, I have been programming python for a little while, now. But as I am beginning to do more complex stuff, I am running into small organization problems. It is possible that what I...
3
by: alan_coffman2004 | last post by:
Opening an ASP.NET VS2002 project in VS2003, am getting this error: "Unable to open Web project 'MyProject'. The file path 'c:\inetpub\wwwroot\MyProject' does not correspond to the URL...
1
by: boops boops | last post by:
Perhaps this is obvious to everyone but me, but how do you rename an existing project when using the .NET IDE? It allows you to save the current form as something else, but not the whole project....
5
by: Jay A. Moritz | last post by:
Error: The dependency '<my dll>' in project '<my project>' cannot be copied to the run directory because it would conflict with dependency '<my dll>'. I am getting a dependency error building...
5
by: schizoid_man | last post by:
Hi, I have a decent amount of programming experience in C/C++ and have recently heard very good things about C#. So I decided to take a look... The lexical elements and language layout make...
49
by: Martin Unsal | last post by:
I'm using Python for what is becoming a sizeable project and I'm already running into problems organizing code and importing packages. I feel like the Python package system, in particular the...
4
by: gardnern | last post by:
I'm trying to find a good solution for project management. In the perfect world, it would be an open-source PHP application that handles Project Management (multiple clients / multiple projects),...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.