# FromFile errors

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

## 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 on other sites
[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 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 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:

//Dialog code, here
OpenFileDialog dialog = new OpenFileDialog();
dialog.ShowDialog();

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

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 16
• 30
• 9
• 16
• 22