# possible to delete file after import?

**URL:** <https://www.dynamicsuser.net/t/possible-to-delete-file-after-import/9784>\
**Category:** Developers Forum\
**Created:** [March 14, 2005, 10:14am UTC](https://www.dynamicsuser.net/t/possible-to-delete-file-after-import/9784 "2005-03-14T10:14:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dina](https://avatars.discourse-cdn.com/v4/letter/d/f0a364/32.png) [@Dina](https://www.dynamicsuser.net/u/Dina)\
**Post date:** [March 14, 2005, 10:14am UTC](https://www.dynamicsuser.net/t/possible-to-delete-file-after-import/9784/1 "2005-03-14T10:14:26Z")

</div>

Hi all, I use dataport to import a txt file and I want to delete the contents of the file after import, is this possible? Do you have any suggestions? I have tried to delete the whole file by using the f.erase(‘file.txt’) in OnPostDataItem but I get the errormessage: ‘file is in use’. Another question; Do you know where I can find information about NAS and automation(the use of it)? I have already read most topic regarding on the forum,also the online help(communication components)… Didn’t get the grip of it… TiA,

---

<div class="post-metadata">

**Author:** ![jatuphot](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@jatuphot](https://www.dynamicsuser.net/u/jatuphot)\
**Post date:** [March 14, 2005, 10:18am UTC](https://www.dynamicsuser.net/t/possible-to-delete-file-after-import/9784/2 "2005-03-14T10:18:41Z")

</div>

Try This Dataport - OnPostDataport() CurrFile.CLOSE; ERASE(CurrDataport.FILENAME);

---

<div class="post-metadata">

**Author:** ![Dina](https://avatars.discourse-cdn.com/v4/letter/d/f0a364/32.png) [@Dina](https://www.dynamicsuser.net/u/Dina)\
**Post date:** [March 14, 2005, 10:34am UTC](https://www.dynamicsuser.net/t/possible-to-delete-file-after-import/9784/3 "2005-03-14T10:34:08Z")

</div>

Thanx:) Had to be CurrFile.CLOSE;ERASE(‘C:\Navision\tempus3.txt’);

---

<div class="post-metadata">

**Author:** ![thomasbrodkorb](https://avatars.discourse-cdn.com/v4/letter/t/2acd7d/32.png) [@thomasbrodkorb](https://www.dynamicsuser.net/u/thomasbrodkorb)\
**Post date:** [March 14, 2005, 2:20pm UTC](https://www.dynamicsuser.net/t/possible-to-delete-file-after-import/9784/4 "2005-03-14T14:20:56Z")

</div>

Try to store the CurrFile.NAME in a text variable and delete the file using that variable after closing the file. I mean your’s is working but hardcoded filenames are always bad practice [;)]

---

<div class="post-metadata">

**Author:** ![Dina](https://avatars.discourse-cdn.com/v4/letter/d/f0a364/32.png) [@Dina](https://www.dynamicsuser.net/u/Dina)\
**Post date:** [March 15, 2005, 11:40am UTC](https://www.dynamicsuser.net/t/possible-to-delete-file-after-import/9784/5 "2005-03-15T11:40:53Z")

</div>

Hi Thomas:) Thanx for pointing out to me what I should have thougth about! Hard code is never a good thing…[xx(] Since you’re always so kind to answer my ignorant questions [:I], maybe you can tell me if it is possible to import two different files through a DataPort? (Without making one file out of their contents) Regards,
