// tries to create a sub-directory // if successful, the sub-directory is deleted // creates the directory if needed - does not delete it private bool TryCreateSubDirectory(string dir) { try { var path = Path.Combine(dir, _ioHelper.CreateRandomFileName()); Directory.CreateDirectory(path); Directory.Delete(path); return(true); } catch { return(false); } }