Sign in to follow this  

[.net] file path questions

This topic is 3734 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im forever getting "Error loading "whatever\file". File not found" and could use some clarification. FOLDER A -file1.txt -FOLDER B (is in folder A) --sourcecode.cs --outputfile.exe --FOLDER C (is in folder b) ---somefile.x so sourcecode.cs would say the location of file1.txt is : @"..\file1.txt" it would also say the location of somefile.x is : @"Folder C\somefile.x" right? When (Ive seen examples) would you ever use a preceeding \ in a file path? K, now something harder. In MSVS Express, Solution Explorer, when you right click and add a new folder, and then add an existing item in there, how do you reference that? Also, there is a Project->Properties GUI that lets you add a resource, how do you tell C# the location of that resource? And whats the difference between : A) having it as a resource by using the GUI just mentioned 2) adding it with add->new item in solution explorer, right click the new item once its displayed in solution explorer, choosing build act = Embedded Resource.

Share this post


Link to post
Share on other sites
1)
When you want to use special characters. It's not such a big deal with filenames cause most special characters aren't available, but it's a string, so that functionality comes with it. It would be pointliess to have a string object specifically for filenames solely for limiting the possible characters.

2)
ProgramNamespace.MyNewFolder.ClassAdded myClass = new ProgramNamespace.MyNewFolder.ClassAdded();

or

using ProgramNamespace.MyNewFolder;
...
ClassAdded myClass = new ClassAdded();

3)
I don't think there is a difference, but check with someone else because I've never ACTUALLY checked.

Share this post


Link to post
Share on other sites
Hmmmm...

Put simply :

I have a ant.bmp file in a folder I created in solution explorer. (picture of an ant)

its properties :
build action = none
copy to output = always

to load it theres a function (using XNA, but that dosent matter)
antTex = content.Load<Texture2D>("\\images\\ant");

No matter what I put in the quotes (and Ive tried every combination of \\ images ant ..\\ there is) I get the error "cant find ant"


Share this post


Link to post
Share on other sites
Nevermind, theres apparently no way to navigate to different folders when using XNA. All your graphics / content must be in the same directory as your source files or they cant be seen by the compiler.

Share this post


Link to post
Share on other sites
yea, and the files are accessed by their name, not their filename when you load them using the content pipeline (ant.bmp == ant).

It's bad form, but you CAN load things from file if you're only planning on deploying to windows platforms (though... that kind of defeats the purpose of using xna).

Share this post


Link to post
Share on other sites

This topic is 3734 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this