![]() |
Relative path to wwwroot for C++ Builder - Printable Version +- Atozed Forums (https://www.atozed.com/forums) +-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html) +--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html) +---- Forum: English (https://www.atozed.com/forums/forum-16.html) +----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html) +----- Thread: Relative path to wwwroot for C++ Builder (/thread-4209.html) |
Relative path to wwwroot for C++ Builder - valmeras - 06-05-2024 I am using C++ Builder 10.2.3 with Intraweb 15.6.1 I am trying to access a subfolder (myfolder) I created in wwwroot following this reference article: https://docs.atozed.com/docs.dll/development/Migrating%20to%20IntraWeb%20XIV.html This for sure does not work as a relative path in C++ builder: "\\myfolder\\myfile.xml" It is referring to C:\myfoler\myfile.xml This one is close: "myfolder\\myfile.xml". But is referring to the application path were the .exe is running! So, in C++ Builder, how can I use a relative path to access a file or subfolder located in wwwroot? RE: Relative path to wwwroot for C++ Builder - joergb - 06-09-2024 (06-05-2024, 03:24 PM)valmeras Wrote: I am using C++ Builder 10.2.3 with Intraweb 15.6.1 maybe its a bug in 15.6.1 ? I use subfolder to store image files. the absolut path is iE: p:\myproject\debug\wwwroot\img and I use only "img" to read or write. I use C-Builder 10.2.3 too, but IW 15.5.9. RE: Relative path to wwwroot for C++ Builder - valmeras - 06-16-2024 I don't know what image [b]joergb [/b]is loading. But I tried Intraweb 15.5.9 and the issue is the same. It works only with TIWImageFile->ImageFile->Filename. For all others like TIWImage->Picture->LoadFromFile and IWMemo->LoadFromFile and TStringLits->LoadFromFile, it does not work! It is exactly as I explained before. It is looking for the folder at the .exe location. So, is that Intraweb normal functioning? RE: Relative path to wwwroot for C++ Builder - MJS@mjs.us - 06-18-2024 >>I am trying to access a subfolder (myfolder) >>I created in wwwroot following this reference article: If I read the article correctly it looks to explain absolute and relative paths in terms of serving content via the web server. >>This for sure does not work as a relative path >>in C++ builder: "\\myfolder\\myfile.xml" It is >>referring to C:\myfoler\myfile.xml This would refer to accessing your files internally from a Windows executable. To use relative paths in this case you would need to know your current directory which generally defaults to the application path. This can change if run from a short cut, run as a service, or changed in code. >>This one is close: "myfolder\\myfile.xml". But >>is referring to the application path were the >>.exe is running! This looks correct to me based on the above. I use something like gGetAppPath()+"wwwroot\\myfoler\\myfile.xml" for file paths in case the current directory isn't set to the application folder. RE: Relative path to wwwroot for C++ Builder - valmeras - 06-25-2024 Yes. This is exactly what I am trying to do: save and retrieve some files from wwwroot. This is exactly what it is supposed to be. And yes, I am using a stand alone application. I know how to access it using the full directory link: IWServerController()->ContentPath This will give you direct access to the contents in the wwwroot as explained in the article. The interest of this question is to be able to use a relative path. I know that I am not paying for priority support. But at least Alexandre from Atozed can answer to this question to tell if it is a bug or the normal functioning? RE: Relative path to wwwroot for C++ Builder - Alexandre Machado - 07-29-2024 As MJS pointed out, the article explains how relative and absolute URL paths are resolved when serving content from the IntraWeb server, not how to access a particular file using the OS file system. The short answer is: You cannot safely use a relative path to access a file on your hard disk. Always use the full path to the file. The longer answer is: In the Windows file system, a relative path is always defined relative to the current working directory. However, the current working directory cannot be safely determined in a multi-threaded application because any thread could possibly change it. In Windows, the current directory is a property of the process, not of individual threads. This means that if one thread changes the current directory, it affects all threads within the same process. IntraWeb itself won't change the current working directory but many 3rd party frameworks do. |