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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

How to get the File from the particular path

(0) ShareShare
ReportReport
Posted on by

Hi All,

I am trying to pick only the filename from the specified path but not able to do that.

Previously i was comparing the filename with the filename that exists in the Folder.

If it was there then i was importing the data to NAV.

But now if in that filepath i have 10 files that starts with "CC" then one by one i have to import all the files.

Below is my code.Please suggest.

Thank u in advance.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Amol Salvi Profile Picture
    18,698 on at

    Your code is not visible .Kindly paste the code again

  • Suggested answer
    Maneesha Profile Picture
    5,891 on at

    Pushpa ,

    your code image/text are missing can you repost it ?

  • Community Member Profile Picture
    on at

    //START-004

    DSVFileName:='CC'+CONVERTSTR(FORMAT(TODAY,0,'<day,2><month,2><year4>'),' ','0')+'.txt';

    IF EXISTS(CustClrSetup.Filepath+DSVFileName) THEN

     CustClrSetup."BAT Text File":= CustClrSetup.Filepath+DSVFileName;

    //STOP-004

    FileName := CustClrSetup."BAT Text File";

    WHILE STRPOS(FileName,'\') > 0 DO

     FileName := COPYSTR(FileName,STRPOS(FileName,'\') + 1);

    PathName := CustClrSetup.Filepath;

    NewFileName:= 'CC'+CONVERTSTR(FORMAT(TODAY,0,'<day,2><month,2><year4>') ,' ','0')+'.txt';

    IF CustClrSetup."BAT Text File" <> PathName  + FileName THEN

     ERROR(Text50000);

    FTPFile.WRITEMODE(TRUE);

    FTPFile.TEXTMODE(TRUE);

    FTPFile.CREATE(PathName + CustClrSetup."FTP File Name");

    FTPFile.WRITE(CustClrSetup."User Name");

    FTPFile.WRITE(CustClrSetup.Password);

    FTPFile.WRITE('lcd C:\');

    FTPFile.WRITE('cd order_sys');

    FTPFile.WRITE('hash');

    FTPFile.WRITE('get ' + FileName);

    FTPFile.WRITE('bye');

    FTPFile.CLOSE;

    BATFile.WRITEMODE(TRUE);

    BATFile.TEXTMODE(TRUE);

    BATFile.CREATE(PathName + CustClrSetup."BAT File Name");

    BATFile.WRITE('C:');

    BATFile.WRITE('FTP -s:' + PathName + CustClrSetup."FTP File Name" + CustClrSetup."Server Address");

    BATFile.CLOSE;

    ReturnCode := SHELL(PathName + CustClrSetup."BAT File Name");

    ERASE(PathName + CustClrSetup."FTP File Name");

    ERASE(PathName + CustClrSetup."BAT File Name");

    }

    IF EXISTS(PathName+FileName) THEN BEGIN

     COPY(PathName+FileName,CustClrSetup."Backup Filepath"+NewFileName);

     ERASE(PathName+FileName);

    END ELSE

     ERROR('Cannot find %1',PathName+FileName);

    ImportFile.TEXTMODE(TRUE);

    ImportFile.OPEN(CustClrSetup."Backup Filepath"+NewFileName);

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans