Windows temporary files behaviour - are they deleted by the system?

前端 未结 7 2155
广开言路
广开言路 2020-12-15 03:28

Using the .net framework you have the option to create temporary files with

Path.GetTempFileName(); 

The MSDN doesn\'t tell us what happens

7条回答
  •  爱一瞬间的悲伤
    2020-12-15 03:53

    They are called temporary because in most cases, the user can assume she can safely clean up the mess in the temp dirs... If not, in general, these files are locked anyway.

    In general, these files should be short lived: create them, use them for whatever need you have, delete them on the spot. At worse, delete them when exiting the application.

    Sometime, you cannot, eg. an archive manager or a VCS allowing to look at a file with an editor (or diff viewer, etc.), but closed before the editor (or not able to monitor the spawned process...).

提交回复
热议问题