web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Business Central file access

(0) ShareShare
ReportReport
Posted on by

Hello,

I would like to know how to access programmatically (without popup) to server local file (text files to import in BC) with BC 14 or higher in web client.

Thanks

I have the same question (0)
  • Community Member Profile Picture
    on at

    I'm not sure that my question is in english... so this is the english version :

    Hello,

    I would like to know how to access programmatically (without popup) to server local file (text files to import in BC) with BC 14 or higher in web client.

    PS : I'm looking for a solution "On Premise"

    Thanks

  • Teddy Herryanto (That NAV Guy) Profile Picture
    14,300 Super User 2026 Season 1 on at

    If you are doing BC in SaaS, there is no easy way to do this because the web browser does not know your server and the pop-up download is also controlled by your browser. You need to use sharepoint or other online file storage.

  • Community Member Profile Picture
    on at

    Thanks Teddy. But I'm not on SaaS version. I'm on a "on premise" version. Is there a solution ?

  • Suggested answer
    Marco Mels Profile Picture
    Microsoft Employee on at

    Hello,

    With BC14, there is still a Windows client but later releases do only have WebClient. With WebClient as Teddy states, this is kind of tricky. So yes, SharePoint is a good candidate to achieve the business goal.

    Thanks.

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at
  • Community Member Profile Picture
    on at

    Thanks to all for your answers.

    I've found a solution and... it was so simple... just remove [RunOnClient] and adding a "\" at the end of the path.

       procedure IntegrationFileByGenJnlBatch(p_JournalTemplateName: Code[10]; p_JournalBatchName: code[10]; p_ShowMessage: Boolean)

       var

           lRecGenJournalBatch: Record "Gen. Journal Batch";

           //[RunOnClient]

           DirectoryImport: DotNet ACYDirectory;

           ArrayList: DotNet ACYArrayList;

           FileInfo: DotNet ACYFileInfo;

           DirectoryFileImport: Text;

           DirectoryFileSave: Text;

           FileImport: Text;

           FileSave: Text;

           car: Text[1];

           fen: Dialog;

           l_i: Integer;

       begin

           if lRecGenJournalBatch.get(p_JournalTemplateName, p_JournalBatchName) then

               if lRecGenJournalBatch.ACYDirectoryFilesImport <> '' then begin

                   if lRecGenJournalBatch.ACYDirectoryFilesSave <> '' then begin

                       DirectoryFileImport := lRecGenJournalBatch.ACYDirectoryFilesImport;

                       DirectoryFileSave := lRecGenJournalBatch.ACYDirectoryFilesSave;

                       car := COPYSTR(lRecGenJournalBatch.ACYDirectoryFilesImport, STRLEN(lRecGenJournalBatch.ACYDirectoryFilesImport), 1);

                       IF Car = '\' THEN

                           DirectoryFileImport := COPYSTR(lRecGenJournalBatch.ACYDirectoryFilesImport, 1, STRLEN(lRecGenJournalBatch.ACYDirectoryFilesImport) - 1);

                       car := COPYSTR(lRecGenJournalBatch.ACYDirectoryFilesSave, STRLEN(lRecGenJournalBatch.ACYDirectoryFilesSave), 1);

                       IF Car = '\' THEN

                           DirectoryFileSave := COPYSTR(lRecGenJournalBatch.ACYDirectoryFilesSave, 1, STRLEN(lRecGenJournalBatch.ACYDirectoryFilesSave) - 1);

                       DirectoryImport := DirectoryImport.DirectoryInfo(DirectoryFileImport);

                       ArrayList := DirectoryImport.GetFiles();

                       if p_ShowMessage then Fen.OPEN('File #1######################################################################');

                       FOR l_i := 0 TO ArrayList.Length - 1 DO BEGIN

                           FileInfo := ArrayList.GetValue(l_i);

                           if p_ShowMessage then Fen.UPDATE(1, FileInfo.FullName);

                           IF FileInfo.Extension = '.txt' THEN begin

                               FileImport := STRSUBSTNO('%1\%2', DirectoryFileImport, FileInfo.Name);

                               FileSave := STRSUBSTNO('%1\%2', DirectoryFileSave, FileInfo.Name);

                               //ExecuteFile(FileInfo.FullName(),

                               //           STRSUBSTNO('%1%2', p_RepertoireArchive, FileInfo.FullName), p_Gap, p_Production);

                               //File.Move(FileInfo.FullName(), STRSUBSTNO('%1%2', DirectoryFileSave, FileInfo.Name));

                               Message(FileImport + ' - ' + FileSave);

                               File.Copy(FileImport, FileSave);

                               file.Erase(STRSUBSTNO('%1\%2', DirectoryFileImport, FileInfo.Name));

                           END;

                       END;

                       if p_ShowMessage then Fen.Close();

                   end else

                       if p_ShowMessage then lRecGenJournalBatch.TestField(ACYDirectoryFilesSave);

               end else

                   if p_ShowMessage then lRecGenJournalBatch.TestField(ACYDirectoryFilesImport);

       end;

  • Suggested answer
    Marco Mels Profile Picture
    Microsoft Employee on at

    Thank you for sharing final solution.

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    If you target your extension for the on-premise world (target = onprem in app.json) using files is the same as in C/AL and NAV. The above code will never work on SaaS but if your target is the onpremise only then stabeard NAV code for managing files will work as usual.

  • Community Member Profile Picture
    on at

    Thanks Stefano. Yes I'm targeting on-premise. And I know that it will not work for SasS. It was just a bug.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,850 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,045 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 959 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans