Change File Name By C/al

CHEMINTELCHEMINTEL Member Posts: 15
edited 2006-06-06 in Navision Attain
it´s posible to change a file name with a c/al code in a codeunit?

Comments

  • KowaKowa Member Posts: 923
    You can create an automation server for 'Microsoft Scripting Runtime'.FileSystemObject ( if you can't find it,Windows Scripting Host has to be installed) and use the methods supplied.
    Kai Kowalewski
  • David_CoxDavid_Cox Member Posts: 509
    Are we talking renaming an existing file?
    Or creating a file from within Navision.

    NewName :='C:\My Files\temp.txt';
    OldName := 'C:\temp.txt';
    IF EXISTS(OldName)THEN
    IF NOT EXISTS(NewName)THEN
    RENAME(OldName,NewName)
    ELSE
    ERROR(NewName+' already Exists')

    Is that what you mean?

    Replace an Old file with a New file same Name
    NewName :='C:\My Files\temp.txt';
    OldName := 'C:\temp.txt';
    IF EXISTS(OldName)THEN BEGIN
    // Delete the destination file first
    IF EXISTS(NewName)THEN
    ERASE(NewName);
    // Move the file
    RENAME(OldName,NewName)
    END;
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
Sign In or Register to comment.