Search code examples
c#.netcreate-directory

Does CreateDirectory apply DirectorySecurity on pre-existing directory?


For CreateDirectory API ( in particular the managed one): https://msdn.microsoft.com/en-us/library/54a0at6s(v=vs.110).aspx

Directory.CreateDirectory Method (String, DirectorySecurity)

If the directory exists, does this call also update the DirectorySecurity?

Or does it silently ignore since the creation failed. Documentation doesn't mention that. It only says: "This object is returned regardless of whether a directory at the specified path already exists."


Solution

  • No it doesn't change the instance of DirectorySecurity in any way. You can check it for yourself here.