[.net] file path questions

Started by
3 comments, last by SnOrfys 16 years, 6 months ago
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.
Advertisement
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.
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"


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.

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).

This topic is closed to new replies.

Advertisement