[.net] File not found? But it's there...

Started by
10 comments, last by jameswren 18 years, 7 months ago
This has really got me stumped so any ideas would be greatly appreciated! My program runs fine on my pc, but on another that meets the requirements and has .net2 beta2 and dx aug05 runtimes installed I get an error when trying to load a texture - system.io.filenotfoundexception...blah blah send error report yes/no box. I've cut my program down while trying to troubleshoot so it only loads a single texture and doesn't even render anything, but it throws the error when trying to load this texture. I've setup a messagebox just before it loads, outputing the full directory/filename it's trying to load, and it's correct on both machines...the dir of the .exe followed by \data\skybox\left.dds. So the file's there, and it's looking in the right place. When i looked in the file's properties, I saw that read-only was greyed and ticked, whatever that means (I'm running winXP with the classic theme - with the xp theme you don't see this greyed-out-ness, only a blue square). So I thought maybe it being read-only is blocking it from being loaded or something, and tryed to un-read-only it, applying to subfolders/files. But everytime I do this, and hit Ok, when I look back in the properties it's grey-ticked again?! I've also copied it to a shared network folder and the shared documents folder on my pc...it runs fine when i log in as guest and run from both locations...but can't run it on the other pc from the network share. So, it runs fine on my pc with admin or guest login from any location, but doesn't work on the other machine from any location. And there's constantly this weird read-only thing going on... As I say, any ideas??
Advertisement
Hey, i dont think that read-only makes the difference because a file or bitmap
that is opened to be displayed and rendered is normaly opened for read but in
some cases, i dont know how you open the file, it is possible you opened it for
read and write, but anyway. I think the problem that read-only is grayed
is because we are talking about parent and child relation. It is possible that
your partition lets say C or D has the option clicked on "Replace permission entries on all child objects with entry shown here that apply to the child objects". This checkbox can be found under the security tab and then advance.
If it isnt on go one level lower check the main store folder if this isnt
checked on go to the next folder in the main folder aso. Till you find
a checked option. This causes all underlying objects including folders,files,
aso to take the parents settings. If you uncheck this one, press apply and then
go to your folder and set the correct security settings and apply it on all bitmap files. During a copy of a file on another computer the security settings
of your pc are not the same. In the new destination the NTFS settings are applied of the main parent folder. That can be the reason.
Also makes sure you open a file like this or pass the parameter like this just
to be on the safe side. "C:\\MLOL\\KKKKK\\KKDKJDLK" \\ is to make sure
that C knows it is \ otherwise he thinks it may be a special feater like
\n newline or \t tab

I hope you understood my explanation. I am from belgium i dont write english
everyday so sorry.
Thanks for your reply.

I have checked and I am using the \\ escape sequence for
Also, when I copy the .exe and data folder onto another computer's shared folder, then run the .exe from my pc, it fails..something to do with kernel.dll I think..so seems like a different problem but nothing major as I'd never be running the .exe from a shared folder normally.

When I right-click C: and click properties, there is no security tab?? I searched google and read that someone had to boot win2k to sort out their file permissions and winXP dumbs down the settings or something? Do you now how to expose these permission for me to change?

Cheers
AFAIK, windows runs the executable in its own path, rather than the path it's actually in. This means if you try to use files local paths, rather than the full path, it probably wont work. However, there is a solution. Create a shortcut to the executable and use that instead, because you can set the exact path that the executable is run in in the shortcut, so you wont encounter this problem (well you shouldn't encounter it).
Thanks, I'm using the full path though:

Application.StartupPath + "\\Data\\Skybox\\left.dds"

and by using a breakpoint I've seen that this directory is the correct directory.
You might want to try to do

File.Exists(filename)


to see whether it is the texture loader that's wrong or not.
Thanks Sijman, I've added that check.

Okay i figured out how to change to permissions, did what Joran said, still the same problem, fiddled the permissions some more and nothing.

This is really starting to be a pain now as I'm doing nothing wrong! Code:

string tmpdir = Application.StartupPath + "\\Data\\Skybox\\left.DDS
MessageBox.Show("Loading texture from " + tmpdir);
MessageBox.Show("The file exists = " + File.Exists(tmpdir));
texture[0] = TextureLoader.FromFile(device, tmpdir);

When I run this on the other machine, a file IO exception is thrown before either of the msgboxes are shown?? And when I comment out the texture[0] line, everything works perfectly, with the file existing and no errors.
Not directly linked to this problem, but you don't have to use the awkward \\ syntax, just use / instead.
So, Application.StartupPath + "\\Data\\Skybox\\left.DDS"; would be Application.StartupPath + "/Data/Skybox/left.DDS";
(I assume the missing "; on your code was a copy-paste mistake).

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

cool thanks for the tip...yep was a copy/paste mistake
I've tried changing this single texture to a random .jpg texture I got off the internet, but still no luck.

This topic is closed to new replies.

Advertisement