How to update file attached to Document without remove old file and re-add ?

Hi everybody, please support me for this situation,

In my case,

1. I created new Document and attached a text file (Document generation = 1)

2. When I update Document, If file is attached have file name is same with old file in Aras server -> My code will remove old file with "delete" action (Document generation  = 2)

3. After that it will re-add new file with "add" action (Document generation  = 3) 

Requirement: After Update document -> Document generation must be 2. And file attached in tag document is only "new file" (If not delete old file and re-add, Aras will be create 2 files with same name but different content)

Thanks so much.