Delete file(s) on hardisk by using Navision

Hi, Maybe a basic question but I want to delete file(s) from my harddisk, in a specific subdirectory. I want to do that within Navision. The thing is this: I created a program to read weborder-files in a specific subdirectory. As soon Navision has imported these weborder-files it has to delete it. I know there is a way to do that, by using the ‘SHELL’ function. But how does this work? And is there a better way to fix my problem? Thanks, Roelof.

Yes you can. Use the File.ERASE function. You can look it up in the C/AL Symbol Menu Lars Strøm Valsted Head of Project and Analysis Columbus IT Partner A/S

I think I was thinking of the file.DELETE function :slight_smile: Also, you may not WANT to delete the files. Are you just deleting them just so you don’t do the same WebOrder twice? Maybe you should somehow flag the WebOrders instead. One simple way might be using a unique ID # for each WebOrder— preferable something found inside the file itself, rather than just the file name. You probably already have a unique order # for each order, which is generated by whatever program it is which has been creating these WebOrder files in the first place. Keep track of those somehow in Navision and have the import routine refuse to import the order if it’s already been imported… ------- Tim Horrigan

Which file.DELETE function?? Lars Strøm Valsted Head of Project and Analysis Columbus IT Partner A/S

Thanks, ‘File.Erase’ helped. But I have another problem. Here is my code: ImportWebOrder.IMPORT(TRUE); FileRec.SETRANGE(Path,SalesSetup.WebOrderFileLocation); FileRec.SETRANGE(“Is a file”,TRUE); //Why does it find here old file(s) again. It suppose to be empty! IF FileRec.FIND(’-’) THEN REPEAT NewImportFile := FileRec.Path + FileRec.Name; ImportWebOrder.FILENAME(NewImportFile); ImportWebOrder.RUNMODAL; FILE.ERASE(NewImportFile); //Delete File CLEAR(ImportWebOrder); UNTIL FileRec.NEXT = 0; CurrForm.UPDATE; ====== For some reason is this routine still finding the old file, when deleted it. Roelof.

I don’t know if we have the same problem. Maybe this solves Your’s. If not maybe someone has a solution tom my little problem. The virtual table “File” seems to be a bit spooky. It seems to me as it doesn’t update properly. When starting Your client it’s allways refreshed, but when client running it doesn’t seem to be updated properly. I developed a routine that “polls” a folder for new files. To get that thing working a had to use SHELL and execute dir and send the output to a file which i read to determine what files that are in the folder. It’s not such a brilliant solution, but it works. //Lars Edited by - Lars Westman on 1/26/01 8:39:52 AM

I had the same problem with the File virtual table and discovered that if you force the File record variable to look at a different folder and then back to your target folder it seems to reset. FileRec.SETRANGE(“Is a file”,TRUE); FileRec.SETRANGE(Path,‘C:’); // Force FileRec to look somewhere IF FileRec.FIND(’-’) THEN; // else, then back to your folder FileRec.SETRANGE(Path,SalesSetup.WebOrderFileLocation);


Yep, it worked! Thanks.