Mega Search
23.2 Million


Sign Up

Make a donation  
reading .ini file with Intraweb 14  
News Group: embarcadero.public.delphi.thirdpartytools.intraweb

I have recently upgraded to IW 14.0.36 from IW 10.0.23.

I have a Standalone Server I'm trying to convert from IW 10 to IW 14.

With IW 10 I was able to open and read an .ini file.  But I have been unable to get this to work in IW 14.  In IW 10, I opened and read the .ini file when creating a new user session.  Below is the code used in IW 10:

procedure TIWUserSession.IWUserSessionBaseCreate(Sender: TObject);
begin
  IniData := TIniFile.Create('files\TIPPS.INI');
  DBConnection.AliasName := IniData.ReadString('Database Name','Name','');
  PhotoLink := IniData.ReadString('Photo Link','Link','');
  InvalidLoginLink := IniData.ReadString('Invalid Login Link','Link','');
  LogoutLink := IniData.ReadString('Logout Link','Link','');
  CompanyName := IniData.ReadString('Company Name','Name','');
  IniData.Free;
end;

With IW 10, I created a folder under the folder in which the SA .exe existed.

I understand that will not work "as is" in IW 14.  Based on my research and reading, it appears this file should be in a folder named wwwroot under folder in which the SA exe exists.  But that is not working either.

Can someone please explain to me where I need to place my .ini files and other text files in order to read them from an IW 14 Standalone Server exe.  

Your help will be appreciated.

Randall

Vote for best question.
Score: 0  # Vote:  0
Date Posted: 18-Jan-2015, at 7:20 PM EST
From: Randall Carpenter
 
Re: reading .ini file with Intraweb 14  
News Group: embarcadero.public.delphi.thirdpartytools.intraweb
> {quote:title=Alexandre Machado wrote:}{quote}
> Hi,
> 
> I always give the INI file the same name of the application (with .ini extension, of course) and save it in the same directory where the main executable is, so I can load it this way:
> 
> {code}
> 
> uses
>   IniFiles, IW.Common.AppInfo;
> 
> procedure TIWForm2.LoadIni;
> var
>   IniFileName: string;
>   IniFile: TIniFile;
> begin
>   IniFileName := ChangeFileExt(TIWAppInfo.GetAppFullFileName, '.ini');
>   IniFile := TIniFile.Create(IniFileName);
>   try
> 
>   finally
>     IniFile.Free;
>   end;
> end;
> 
> {code}
> 
> In this case, I'm using IW's utility class TIWAppInfo to get the full name of the binary file (SA executable or ISAPI DLL name), change its extension and use it as the INI file name.
> 
> works perfectly. I don't recommend storing INI files in web accessible folders (any folder below wwwroot).
> 
> Best regards


Hey guys,

Thanks very much for your help.  

I really wanted to mark both these answers as correct because they are both correct.  I tried both ways and they both work.  

I marked the first one as correct since it answers my specific question.  

However, Alexandro's answer may be a better solution because it should provide better security since it better limits access to these files.

Thanks very much to both of you.

Randall H. Carpenter

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 19-Jan-2015, at 10:01 AM EST
From: Randall Carpenter
 
Re: reading .ini file with Intraweb 14 [Edit]  
News Group: embarcadero.public.delphi.thirdpartytools.intraweb
Hi,

I always give the INI file the same name of the application (with .ini extension, of course) and save it in the same directory where the main executable is, so I can load it this way:

{code}

uses
  IniFiles, IW.Common.AppInfo;

procedure TIWForm2.LoadIni;
var
  IniFileName: string;
  IniFile: TIniFile;
begin
  IniFileName := ChangeFileExt(TIWAppInfo.GetAppFullFileName, '.ini');
  IniFile := TIniFile.Create(IniFileName);
  try

  finally
    IniFile.Free;
  end;
end;

{code}

In this case, I'm using IW's utility class TIWAppInfo to get the full name of the binary file (SA executable or ISAPI DLL name), change its extension and use it as the INI file name.

works perfectly. I don't recommend storing INI files in web accessible folders (any folder below wwwroot).

Best regards

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 19-Jan-2015, at 3:15 AM EST
From: Alexandre Machado
 
Re: reading .ini file with Intraweb 14  
News Group: embarcadero.public.delphi.thirdpartytools.intraweb
IniData := TIniFile.Create(IWServerController.ContentPath  + 'TIPPS.INI');

And copy your 'TIPPS.INI' file in the wwwroot directory. Works for me, both Stand Alone and as ISAPI.

Cees


> {quote:title=Randall Carpenter wrote:}{quote}
> I have recently upgraded to IW 14.0.36 from IW 10.0.23.
> 
> I have a Standalone Server I'm trying to convert from IW 10 to IW 14.
> 
> With IW 10 I was able to open and read an .ini file.  But I have been unable to get this to work in IW 14.  In IW 10, I opened and read the .ini file when creating a new user session.  Below is the code used in IW 10:
> 
> procedure TIWUserSession.IWUserSessionBaseCreate(Sender: TObject);
> begin
>   IniData := TIniFile.Create('files\TIPPS.INI');
>   DBConnection.AliasName := IniData.ReadString('Database Name','Name','');
>   PhotoLink := IniData.ReadString('Photo Link','Link','');
>   InvalidLoginLink := IniData.ReadString('Invalid Login Link','Link','');
>   LogoutLink := IniData.ReadString('Logout Link','Link','');
>   CompanyName := IniData.ReadString('Company Name','Name','');
>   IniData.Free;
> end;
> 
> With IW 10, I created a folder under the folder in which the SA .exe existed.
> 
> I understand that will not work "as is" in IW 14.  Based on my research and reading, it appears this file should be in a folder named wwwroot under folder in which the SA exe exists.  But that is not working either.
> 
> Can someone please explain to me where I need to place my .ini files and other text files in order to read them from an IW 14 Standalone Server exe.  
> 
> Your help will be appreciated.
> 
> Randall

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 18-Jan-2015, at 11:28 PM EST
From: Cees Glas