# Permission problem

**URL:** <https://forums.swift.org/t/permission-problem/69132>\
**Category:** Windows\
**Created:** [December 22, 2023, 3:20pm UTC](https://forums.swift.org/t/permission-problem/69132 "2023-12-22T15:20:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniero](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/daniero/32/32118_2.png) [@daniero](https://forums.swift.org/u/daniero)\
**Post date:** [December 22, 2023, 3:20pm UTC](https://forums.swift.org/t/permission-problem/69132/1 "2023-12-22T15:20:38Z")

</div>

Hi,

I just tried to remove the .build folder and I got this error:

```swift
Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission."

```

But I'm the administrator of my computer and yes, I tried to remove it "as administrator"

Plus... Cocoa? I'm on Windows... 😕

Windows 11  
Swift 5.9.2

Any idea?

---

<div class="post-metadata">

**Author:** ![compnerd](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/compnerd/32/2165_2.png) [@compnerd](https://forums.swift.org/u/compnerd)\
**Post date:** [December 22, 2023, 10:39pm UTC](https://forums.swift.org/t/permission-problem/69132/2 "2023-12-22T22:39:28Z")

</div>

It could be that something is holding on to the directory. You may have it open in explorer, in a terminal, or perhaps an editor?

---

<div class="post-metadata">

**Author:** ![daniero](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/daniero/32/32118_2.png) [@daniero](https://forums.swift.org/u/daniero)\
**Post date:** [December 23, 2023, 10:56am UTC](https://forums.swift.org/t/permission-problem/69132/3 "2023-12-23T10:56:00Z")

</div>

Thank you Saleem for your reply.

Yes I double checked if any process was blocking access, as any windows user painfully learnt to do 🙂  
I use one of the tools in windows very own power toys. However the tool couldn't find anything.  
Obviously a process was holding those files though, because after a full reboot, I was able to delete the folder.

This is not the first time I encounter that issue, so I was hoping it was something common and that maybe a simple fix was known.

---

<div class="post-metadata">

**Author:** ![compnerd](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/compnerd/32/2165_2.png) [@compnerd](https://forums.swift.org/u/compnerd)\
**Post date:** [December 26, 2023, 8:18pm UTC](https://forums.swift.org/t/permission-problem/69132/4 "2023-12-26T20:18:25Z")

</div>

> [@daniero](#):
>
> Obviously a process was holding those files though, because after a full reboot, I was able to delete the folder.

Not necessarily - it _could_ have been a zombie lock. The process could have terminated without relinquishing a lock, the kernel could have inherited it. The way to get around deletion is to use something like:

```c
MoveFileExW(pwszFile, L"NUL", MOVEFILE_DELAY_UNTIL_REBOOT);

```

This allows for deleting the file on the next reboot.
