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 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.
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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....
|
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...
|
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...
|
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....
|
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...
|
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...
|
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...
|
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),...
|
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...
|
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
|
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...
|
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...
|
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,...
|
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...
|
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,...
|
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...
|
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...
| | |