Thk u for your answer.

I have used static implementation of rename,problem still exists.

I want to modify some contents of a text file,and do as follows:
1.open the text file(a.txt),and read the contents of it and modify some of it.
2.write the modified contents in a new file(b.txt);
3.delete a.txt
4.rename b.txt to a.txt.

now rename can not work properly,what other ways should I go?