can we lock a directory?

前端 未结 2 1019
予麋鹿
予麋鹿 2021-01-06 12:10

I am using VSTS 2008 + C# + .Net 3.5 to develop a console application. For file access, we can access file in exclusive mode which blocks other process/thread from access th

相关标签:
2条回答
  • 2021-01-06 12:58

    I think what you can do is set the directory's Access Control and then change it back when your done. Have a look here:

    http://msdn.microsoft.com/en-us/library/system.io.directory.setaccesscontrol.aspx

    0 讨论(0)
  • 2021-01-06 13:12

    If it is your own process that might interfere you can use a named Mutex to synchronize. It is very hard to keep out other processes, the usual approach is to evade to a temp (hidden) dir, do your work and copy/move the results back.

    0 讨论(0)
提交回复
热议问题