Options

Directory / Several files in a directory

miabusomiabuso Member Posts: 4
I want to work with several files in the same directory.
I use a expression like "c:\*.txt", then open all files with "txt" in directory "c:\", and make a process with all files (one by one).

¿Do it exists any way to do that in NAV 5.0?

Thank you very much.

Comments

  • Options
    kinekine Member Posts: 12,562
    Yes, just search the forum for virtual table "file".
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    garakgarak Member Posts: 3,263
    take a look to table 2000000022 (u can only see it if you add it as variable or create a form based on this table.
    Search also the forum for 2000000022. I'm sure there are a lot of topics.

    regards
    Do you make it right, it works too!
  • Options
    bbrownbbrown Member Posts: 3,268
    Windows Scripting is another option. This is an example the prepares a list of files, in a folder, and then allows them to be processed. I got this idea from another Mibuso posting and modified to meet my needs. I use this is a NAS process to grab files from a remote folder.

    Variables
    FileSystem = "Windows Script Host Object Model'.FileSystemObject"
    Folder = "'Windows Script Host Object Model'.Folder"
    Files = 'Windows Script Host Object Model'.Files
    WFile = 'Windows Script Host Object Model'.File
    DictionaryFiles = 'Microsoft Scripting Runtime'.Dictionary
    ScriptControl = 'Microsoft Script Control 1.0'.ScriptControl
    Script = Text(250)
    CrLf = Text(2)
    i= integer
    n = integer
    
    
    Code
    Folder := FileSystem.GetFolder(Path);
    Files := Folder.Files;
    
    ScriptControl.Language := 'VBScript';
    ScriptControl.AddObject('FilesByName', Files);
    ScriptControl.AddObject('FilesById', DictionaryFiles);
    CrLf := ' ';
    CrLf[1] := 13;
    Script := 'dim f1' + CrLf +
              'For Each f1 in FilesByName' + CrLf +
              ' FilesById.Add (FilesById.Count + 1), f1' + CrLf +
              'Next' + CrLf;
    ScriptControl.ExecuteStatement(Script);
    CLEAR(ScriptControl);
      FOR n := 1 TO DictionaryFiles.Count DO BEGIN 
        WFile := DictionaryFiles.Item(n);
        // Process Each file in this loop
        // WFile.Name holds files name
      END; 
    
    
    There are no bugs - only undocumented features.
Sign In or Register to comment.