[Gambas-user] Exist says OK, but the File.Load fails

Benoît Minisini gambas at ...1...
Thu Nov 19 13:10:23 CET 2009


> Salut,
> 
> this is my code (I added the line numbers)
> Exist says OK
> but the File.Load fails with : File or directory does not exist
> 
> args[0] = Reports/US-presidents-3.xml is a relative path
> If I use the Fullpath it works.
> 
> AND: this only happens if the code is used in a component !
>      In the project-code it works.
> 
> 807  IF Exist(args[0]) THEN
> 808
> 809    sString = File.Load(args[0])
> 
> This I get if I run it :
> 
> args[0] = Reports/US-presidents-3.xml
> 
> CLogic.FromXML.809: #45: File or directory does not exist
> 

A relative path is resolved inside the project. So if you use your project as 
a component, the file must be inside the component, otherwise it won't work.

If you want a component to access a file located inside the project that uses 
this component, there is a trick: starting the relative path with "../".

But Exist() should be coherent with File.Load(), so can you send me the code, 
so that I have a clear view of what you do?

Regards,

-- 
Benoît Minisini





More information about the User mailing list