FILE RECORDSET

clemboclembo Member Posts: 122
edited 2013-06-25 in NAV Three Tier
I've this code in Nav 2013:
(RecFile = Recordset FILE)

RecFile.RESET;
recFile.SETCURRENTKEY(Path,"Is a file",Name);
recFile.SETRANGE("Is a file",TRUE);
recFile.SETRANGE(Path,'C:\TEST;
IF recFile.FINDSET THEN REPEAT
ETC..

But when execute page no file was found.
There is a problem with Nav 2013?

This code work great in Nav 2009 R2..

Comments

  • tulliotullio Member Posts: 39
    Nav 2009 R2 RTC
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    In both cases, Servicetier installed on same machine or not?
  • clemboclembo Member Posts: 122
    mmmhh.. I don't Know ..
  • thegunzothegunzo Member Posts: 274
    is you C:\TEST folder on the server computer or on you client computer ?
    ________________________________
    Gunnar Gestsson
    Microsoft Certified IT Professional
    Dynamics NAV MVP
    http://www.dynamics.is
    http://Objects4NAV.com
  • geordiegeordie Member Posts: 655
    Try to modify the code as following:
    recFile.RESET;
    recFile.SETCURRENTKEY(Path,"Is a file",Name);
    recFile.SETRANGE("Is a file",TRUE);
     
    recFile.SETRANGE(Path,'C:\');
    IF recFile.FINDSET THEN;
     
    recFile.SETRANGE(Path,'C:\TEST');
    IF recFile.FINDSET THEN REPEAT
    ...
    

    I faced the same problem and solved forcing to look in a different path before the search I wanted to perform in order to update the table.
  • clemboclembo Member Posts: 122
    Nothing. Not work.

    There is a way to list all file in a folder.. I think..
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    There will be a way but first you have tell us whether servicetier is installed in your machine on server?
  • thegunzothegunzo Member Posts: 274
    Take a look at the System.IO. objects in mscorlib and use the dotnet interopt method. Use RunOnClient if the files are on the client computer.
    ________________________________
    Gunnar Gestsson
    Microsoft Certified IT Professional
    Dynamics NAV MVP
    http://www.dynamics.is
    http://Objects4NAV.com
  • tulliotullio Member Posts: 39
    Servicetier is installed on server.
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    RTC will be checking for files in Server machine under 'C:\TEST' path.
    You need to either manually upl;oad the files to server or write code to upload the files from user machine to server.

    Or try thegunzo's suggestion.
  • clemboclembo Member Posts: 122
    Problem is I don't know wich files foudn in this folder.
    Target is read all files in that folder with filename start with customer*.txt but I can't know before wich file found.
  • thegunzothegunzo Member Posts: 274
    Perhaps this will help.
    OBJECT Codeunit 50000 UnzipAndImport
    {
      OBJECT-PROPERTIES
      {
        Date=25.06.13;
        Time=11:48:39;
        Modified=Yes;
        Version List=Dynamics.is;
      }
      PROPERTIES
      {
        OnRun=BEGIN
              END;
    
      }
      CODE
      {
        VAR
          ServerDirectory@1000000004 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.Directory";
          ServerPath@1000000006 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.Path";
          ServerFile@1200050027 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.File";
          ServerZipFile@1000000005 : DotNet "'System.IO.Compression.FileSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.Compression.ZipFile";
          ServerExtractedFiles@1000000007 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Array";
          FileMgt@1200050025 : Codeunit 419;
    
        PROCEDURE UnZipAndImport@1200050001(ZipFileName@1200050001 : Text[1024]);
        VAR
          TempFileName@1200050008 : Text[1024];
          TempFolderName@1200050003 : Text[1024];
          Index@1200050004 : Integer;
        BEGIN
          TempFolderName := FileMgt.GetDirectoryName(ZipFileName) + 'NAV_UNZIP';
          IF ServerDirectory.Exists(TempFolderName) THEN BEGIN
            ServerDirectory.Delete(TempFolderName,TRUE);
            SLEEP(100);
          END;
    
          ServerZipFile.ExtractToDirectory(ZipFileName,TempFolderName);
          ServerExtractedFiles := ServerDirectory.GetFiles(TempFolderName);
          IF ServerExtractedFiles.Length > 0 THEN
            FOR Index := 1 TO (ServerExtractedFiles.Length) DO BEGIN
              TempFileName := ServerExtractedFiles.GetValue(Index - 1);
              // Do what you like with TempFileName
              ServerFile.Delete(TempFileName);
            END;
    
          IF ServerDirectory.Exists(TempFolderName) THEN
            ServerDirectory.Delete(TempFolderName,TRUE);
        END;
    
        BEGIN
        END.
      }
    }
    
    
    ________________________________
    Gunnar Gestsson
    Microsoft Certified IT Professional
    Dynamics NAV MVP
    http://www.dynamics.is
    http://Objects4NAV.com
Sign In or Register to comment.