Jump to content
  • Advertisement
Sign in to follow this  
MikeyO

FromFile errors

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

Mesh.FromFile and TextureLoader.FromFile are crashing whenever I use an OpenFileDialog before trying to load them. If I type in the location of the file instead of using a dialog box, the texture and mesh are loaded fine. I cannot imagine what the problem is because I haven't had any trouble with this before now in other programs that do almost exactly the same thing. All I get now is "Error in the application" Anyone have any ideas?

Share this post


Link to post
Share on other sites
Advertisement
[rambling]

Is the path that is gotten from the dialogue in correct form. There was a post earlier where someone wasn't putting \\ instead of \.

ace

[/rambling]

Share this post


Link to post
Share on other sites
Are you sure you're using OpenFileDialog correctly? It's pretty probable you are, because if it works with a hardcoded string, it should work there.

That's the only thing I can think of.

Share this post


Link to post
Share on other sites
Im not even using the OpenFileDialog, actually. I was using it, but now I'm only using ShowDialog() and then a string that I've already hardcoded,

For example:

TextureLoader.FromFile(@"whatever.bmp"); //Works
//Dialog code, here
OpenFileDialog dialog = new OpenFileDialog();
dialog.ShowDialog();
TextureLoader.FromFile(@"whatever.bmp"); //Doesn't work.

The problem seems to be that after I open the dialog, I can no longer load files.. but rendering still seems to work fine.

Share this post


Link to post
Share on other sites
It seems to work fine if I hit cancel on the dialog box as well.


private string GetFile()
{
System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
dialog.Filter = "DirectX DDS (*.dds)|*.dds|Bitmap (*.bmp)|*.bmp|Jpeg (*.jpg)|*.jpg|All Files (*.*)|*.*";
System.Windows.Forms.DialogResult r = dialog.ShowDialog();

if(r.Equals(System.Windows.Forms.DialogResult.OK))
{
string name = dialog.FileName;
dialog.Dispose();
dialog = null;

if(System.IO.File.Exists(name))
return System.IO.Path.GetFileName(name);
return null;
}

return @"engineTex.bmp";
}


The path is added back in later, and I'm sure the file exists.. it doesn't give a FileNotFound exception either.

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!