Jump to content
  • Advertisement
Sign in to follow this  
m4gnus

debuggersays file.good()=false usual run true...

This topic is 4876 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

Hi My problem is that when i run my small programm that imports a model file runs through the Vs .net 2003 debugger my message box pops up saying that the modellfile wasn't found (file.good()=false) but when i run it "usually" (running the .exe through the explorer) the messagebox doesn't pop up. So my first (main) problem is why doesn't it find the file if just tell him to open "test2.ngm" and the file is in the same folder than the .exe? But as running the .exe doesn't result in an error i'm not even sure if it doesn't find the model. So why does the debugger say file.good()=false and the usual .exe file.good()=true? My code:
	std::ifstream file;
	file.open("test2.ngm",std::ios::in,std::ios::binary);
	if(file.good()) 
	{
	//Load vertices:
	file.read(reinterpret_cast<char*>(&VertHeader),sizeof(VertHeader));
	DWORD VChunkSize=VertHeader.dwDataSize;
	file.read(reinterpret_cast<char*>(&VertChunkHeader),sizeof(VertChunkHeader));
	for(DWORD i=0;i<VertChunkHeader.dwNumVertices;i++) 
	{
		Vertex vert;
		file.read(reinterpret_cast<char*>(&vert),sizeof(vert));
		Verts.push_back(vert);
	}

	//Load Indices:
	file.read(reinterpret_cast<char*>(&IndexHeader),sizeof(IndexHeader));
	DWORD IChunkSize=IndexHeader.dwDataSize;
	file.read(reinterpret_cast<char*>(&IndexChunkHeader),sizeof(IndexChunkHeader));
	for(DWORD i=0;i<IndexChunkHeader.dwNumIndices;i++) 
	{
		short index;
		file.read(reinterpret_cast<char*>(&index),sizeof(index));
		Indices.push_back(index);
	}
	}else{
		MessageBox(0,"File not found!","Error",0);
        PostQuitMessage(1);

	}

regards, m4gnus

Share this post


Link to post
Share on other sites
Advertisement
I'm not sure if this is still the case with VC7. In VC6, though, the compiled program is placed in a sub directory (Debug/Release) of the project. The IDE runs the executable with the project dir as the working directory. So any files with no pathnames are opened from there. If you run the program from the subdir, the program will try to open the files from the subdir, but they are not there.

If you don't get what I mean:

C:\Project
- VS files
- source files
- important file the app needs
Debug
- program exe


Greetz,

Illco

Share this post


Link to post
Share on other sites
Ilco is correct.

You can change the default directory by adding a full path (or a path relative to the project directory) under Project->Properties->Debugging->Working Directory for each release.

This means that when you run the exe in the debugger, it will run with that directory as it's working directory.

Share this post


Link to post
Share on other sites
oh ok that was the problem...now i only have to figure out why my MeshClass renders nothing :(

thx

regards,
m4gnus

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!