How to get the "Temporary Navision Path"

eromeineromein Member Posts: 589
edited 2013-11-07 in Navision Attain
Hi,

Does anybody know how to get the "Temporary Navision Path" (TempFilePath from Navision options) within Navision. I need this path to save a Temporary file.

If this is not possible I would like to get the Windows Temporary path.

Thanks,

Emiel Romein
"Real programmers don't comment their code.
If it was hard to write, it should be hard to understand."

Comments

  • lessilessi Member Posts: 33
    Hello,

    This is the way i use to use the Windows temporary folder.

    ============================
    txtPath:=ENVIRON('temp');
    IF txtPath='' THEN
    ERROR('unknowned variable TEMP');
    IF COPYSTR(txtPath,STRLEN(txtPath),1)<>'\' THEN
    txtPath:=INSSTR(txtPath,'\',STRLEN(txtPath)+1);
    recFile.RESET;
    recFile.SETRANGE(Path,txtPath);
    IF NOT(recFile.FIND('-')) THEN
    ERROR('TEMP not set');

    =============================

    Hope it could help you,

    Regards,
  • SavatageSavatage Member Posts: 7,142
    While in Navision if you go to TOOLS->OPTIONS
    It shows you the TempFilePath. You can change it if you'd like.

    -Is this what you are asking about?
  • eromeineromein Member Posts: 589
    Is there an ENVIRON parameter to get the Navision Temp. path?
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • Luc_VanDyckLuc_VanDyck Kontich (Belgium)Member, Moderator, Administrator Posts: 3,633
    Try this code to get the TempPath:

    Vars
    Name	                DataType	Subtype	Length
    filFile	             File		
    txtFileName	         Text		           250
    txtTempPath	         Text		           250
    i	                   Integer		
    
    
    filFile.CREATETEMPFILE;
    txtFileName := filFile.NAME;
    filFile.CLOSE;
    FOR i := STRLEN(txtFileName) DOWNTO 1 DO BEGIN
      IF COPYSTR(txtFileName,i,1) = '\' THEN BEGIN
        txtTempPath := COPYSTR(txtFileName,1,i - 1);
        i := 0;
      END;
    END;
    MESSAGE('TempPath = %1',txtTempPath);
    

    It uses the CREATETEMPFILE function, which is available from Attain 3.60.
    No support using PM or e-mail - Please use this forum.
    NAV TechDays 2022: 17 & 18 November 2022, Antwerp (Belgium)
  • eromeineromein Member Posts: 589
    Great Stuff!

    Thx y'all!
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • tomtrortomtror Member Posts: 3
    I think there is an easier way: :roll:
    TempPath := ENVRION('TMP');
    

    But be careful: Navision's TempFilePath is the TMP environment variable, not the TEMP variable. It's set on startup and will not be update during a running session.
  • SavatageSavatage Member Posts: 7,142
    that post was from 2003
  • primeapprimeap Member Posts: 36
    and time has evolved..
    since NAV 2009 we can use the system function: TEMPORARYPATH

    http://msdn.microsoft.com/en-us/library/dd338849.aspx
  • drotunnodrotunno Member Posts: 2
    Hi all. I have a strange problem. My TEMPORARYPATH var in nav 5 return ...local\Temp indeed ..local\Temp\ID\

    What can be the problem?

    Thanks
Sign In or Register to comment.