<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2018-08-19 13:58 GMT+02:00 Tobias Boege <span dir="ltr"><<a href="mailto:taboege@gmail.com" target="_blank">taboege@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Sun, 19 Aug 2018, Gianluigi wrote:<br>
> 2018-08-19 11:47 GMT+02:00 Tobias Boege <<a href="mailto:taboege@gmail.com">taboege@gmail.com</a>>:<br>
> <br>
> > On Sat, 18 Aug 2018, Hans Lehmann wrote:<br>
> > > Hello Charlie,<br>
> > ><br>
> > > what is special about the following line with regard to the path<br>
> > > specification:<br>
> > ><br>
> > > Dim sFile As String = File.Load("../.project")<br>
> > ><br>
> > > ?<br>
> > ><br>
> ><br>
> > This is documented here: <a href="http://gambaswiki.org/wiki/cat/path" rel="noreferrer" target="_blank">http://gambaswiki.org/wiki/<wbr>cat/path</a><br>
> ><br>
> > A relative path starting with ".." references a data file in the<br>
> > currently running *project*, even if that code is executed from<br>
> > a component or library.<br>
> ><br>
> > Regards,<br>
> > Tobi<br>
> ><br>
> > --<br>
> > "There's an old saying: Don't change anything... ever!" -- Mr. Monk<br>
> ><br>
> <br>
> Hi Tobias,<br>
> I find this explanation of the wiki unclear.<br>
> From it, after compilation, it would seem that the concept of the "current<br>
> project" no longer exists.<br>
<br>
It very much exists. The "current project" is where relative paths are<br>
resolved to. What you don't have is a "current working directory".<br>
<br>
> But this simple code should work even after compilation, right?<br>
> <br>
> Note: The file "foo.txt" is located inside the project data folder.<br>
> <br>
> Public Sub Main()<br>
> <br>
>   Dim sPath As String = "/tmp/path-test"<br>
> <br>
>   Try Mkdir sPath<br>
>   If Error Then Return<br>
>   Try Copy "./foo.txt" To sPath &/ "foo.txt"<br>
> <br>
> End<br>
> <br>
<br>
Yes, this copies the file "foo.txt" in your project directory to the<br>
temporary location. The difference between "." and ".." (BTW, "./foo.txt"<br>
is the same as "foo.txt", even in this context) is that if you write a<br>
component or library and load "foo.txt" in code running inside the<br>
component, you access resources of the component project, not of the<br>
project that is currently running and using that component.<br>
<br>
If you want access from the component code to resources in the currently<br>
running project, then you use "../foo.txt". gb.web.form does this,<br>
for example, to serve files in your project's .public folder (think favicon,<br>
css and javascript resources) without you having to think about it.<br>
<br>
All of that works no matter if you are executing the project from the IDE,<br>
from the project directory or a compiled .gambas archive.<br>
<br>
Regards,<br>
Tobi<br>
<span class="gmail-HOEnZb"><font color="#888888"><br>
-- <br>
"There's an old saying: Don't change anything... ever!" -- Mr. Monk</font></span></blockquote><div><br></div><div><br></div><div>Hi Tobias,<br>one final clarification.<br>When you write:<br>"If you want access from the component code to resources in the currently running project, then you use "../foo.txt".<br>gb.web.form does this, for example, to serve files in your project's .public folder (think favicon, css and javascript resources) without you having to think about it."<br>You mean that with "../" we access files in read-only mode, right?<br>If we need to write to the file we have to copy it to a user directory (e.g. Try Copy "./foo.txt" To sPath &/ "foo.txt")<br><br>Regards<br>Gianluigi <br></div></div></div></div>