Recent

Author Topic: path finding  (Read 10360 times)

mangakissa

  • Hero Member
  • *****
  • Posts: 1131
path finding
« on: October 07, 2014, 06:13:00 pm »
I created a small application which is running a dataset. this dataset will  be saved as a textfile.
When I using 'assign(F,'sample.txt') and my application runs on temp in wince, my file is saved in the root. But why? How do I find the temp directory or my documents or application directory on winCE with Lazarus?
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: path finding
« Reply #1 on: October 07, 2014, 06:33:59 pm »
Code: [Select]
function AppFolder:String;
begin
  Result := ExtractFileDir(Application.ExeName);
end;
That should work on all windows systems.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1260
Re: path finding
« Reply #2 on: October 07, 2014, 07:37:26 pm »
GetTempDir doesn't look like it's got any OS specific calls (just requires Environment TEMP being defined...)
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

mangakissa

  • Hero Member
  • *****
  • Posts: 1131
Re: path finding
« Reply #3 on: October 07, 2014, 08:53:03 pm »
winCE is not window specific. It doesn't use drive letters to combine. The Environment TEMP doesn't exists, because I created myself.
winCE has 4 mountpoints
- /
- application
- my documents
- windows (i'm not sure about this one, device is at the office)

I could try extractfiledir(), but that doesn't give me (for example) My documents\textfiles to copy the file into
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

rvk

  • Hero Member
  • *****
  • Posts: 6110
Re: path finding
« Reply #4 on: October 07, 2014, 10:18:38 pm »
I think WinCE doesn't know the concept of "Working directory" so if you save a file without specifying the full path it won't end up in your "Program directory". (It's somewhere in here)

Could you try getting the full program-filename and derive the path to put before sample.txt?

Code: [Select]
var
  lpFileName: array[MAX_PATH+1] of Char;
begin
  GetModuleFileName(NULL, lpFileName, MAX_PATH);
  {...}

mangakissa

  • Hero Member
  • *****
  • Posts: 1131
Re: path finding
« Reply #5 on: October 08, 2014, 01:14:22 pm »
My apologies to Taaz.
WinCE doesn't use driveletters, but has one mountingpoint called '\'. My application in temp can be found in \temp.
On my device a treefolder example is installed and this tells me 'My Documents' is actually '\My Documents'.
So WinCE does exactly do what Windows does.


Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

 

TinyPortal © 2005-2018