# REMOVE(file) vs. ds\_DeleteFile(file) == 22 seconds vs. 2 seconds on RDP!

**URL:** <https://clarionhub.com/t/remove-file-vs-ds-deletefile-file-22-seconds-vs-2-seconds-on-rdp/6709>\
**Category:** tips\
**Tags:** delete\
**Created:** [October 20, 2023, 5:54am UTC](https://clarionhub.com/t/remove-file-vs-ds-deletefile-file-22-seconds-vs-2-seconds-on-rdp/6709 "2023-10-20T05:54:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![RichCPT](https://clarionhub.com/letter_avatar_proxy/v4/letter/r/e19b73/32.png) [@RichCPT](https://clarionhub.com/u/RichCPT)\
**Post date:** [October 20, 2023, 5:54am UTC](https://clarionhub.com/t/remove-file-vs-ds-deletefile-file-22-seconds-vs-2-seconds-on-rdp/6709/1 "2023-10-20T05:54:50Z")

</div>

FYI:  
Running my C11 program on an RDP session in an Azure production server, I found that deleting one client-side file, on a redirected drive, was taking 22 seconds!

After replacing the REMOVE(filename) with ds\_DeleteFile(filename), from CapeSoft’s “WinEvent” product, it now takes less than 2 seconds!

Thanks Bruce and Carl.

---

<div class="post-metadata">

**Author:** ![KevinErskine](https://clarionhub.com/user_avatar/clarionhub.com/kevinerskine/32/711_2.png) [@KevinErskine](https://clarionhub.com/u/KevinErskine)\
**Post date:** [October 20, 2023, 11:13pm UTC](https://clarionhub.com/t/remove-file-vs-ds-deletefile-file-22-seconds-vs-2-seconds-on-rdp/6709/2 "2023-10-20T23:13:04Z")

</div>

Yes, there was a great discussion on this matter using windows api vs clarion remove

Win32\_DeleteFile PROCEDURE(\*CSTRING lpFileName ),BOOL,PROC,RAW,PASCAL,DLL(1),name(‘DeleteFileA’) !Win API way to Delete a File  
Win32\_GetLastError PROCEDURE(),LONG,PASCAL,DLL(1),NAME(‘GetLastError’)

---

<div class="post-metadata">

**Author:** ![anon77170705](https://clarionhub.com/letter_avatar_proxy/v4/letter/a/ecccb3/32.png) [@anon77170705](https://clarionhub.com/u/anon77170705)\
**Post date:** [October 20, 2023, 11:44pm UTC](https://clarionhub.com/t/remove-file-vs-ds-deletefile-file-22-seconds-vs-2-seconds-on-rdp/6709/3 "2023-10-20T23:44:22Z")

</div>

> [@KevinErskine](#):
>
> Yes, there was a great discussion on this matter using windows api vs clarion remove

Clarion REMOVE is Windows API’s SHFileOperation… Among other thing REMOVE supports wildcards in the passed file name, though the name should not begin with a wildcard characters^

`REMOVE('??.*')`

will fail but

`REMOVE ('.\??.*')`

must work.

---

<div class="post-metadata">

**Author:** ![jslarve](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jslarve](https://clarionhub.com/u/jslarve)\
**Post date:** [October 21, 2023, 12:18am UTC](https://clarionhub.com/t/remove-file-vs-ds-deletefile-file-22-seconds-vs-2-seconds-on-rdp/6709/4 "2023-10-21T00:18:21Z")

</div>

Perhaps it could have had some logic to decide whether a call to SHFileOperation was warranted, or if the faster way could be used.

Until somebody figured out what was happening, all of a sudden everyone’s apps slowed way down when temp report files were removed. Not a nice surprise, when you have a lot of pages. It seems to the user like the app is frozen, and then they kill it.

---

<div class="post-metadata">

**Author:** ![anon77170705](https://clarionhub.com/letter_avatar_proxy/v4/letter/a/ecccb3/32.png) [@anon77170705](https://clarionhub.com/u/anon77170705)\
**Post date:** [October 21, 2023, 12:39am UTC](https://clarionhub.com/t/remove-file-vs-ds-deletefile-file-22-seconds-vs-2-seconds-on-rdp/6709/5 "2023-10-21T00:39:40Z")

</div>

It’s Shell’s work to decide how execute SHFileOperation optimally depending from parameters and from kinds of involved files’ locations. If it not works well in case of processing files via Remote Desktop Protocol, this is the Shell’s problem. Though SHFileOperation works good for local and networked (e.g. using SMB or NFS protocols) files.

---

<div class="post-metadata">

**Author:** ![jslarve](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jslarve](https://clarionhub.com/u/jslarve)\
**Post date:** [October 21, 2023, 12:58am UTC](https://clarionhub.com/t/remove-file-vs-ds-deletefile-file-22-seconds-vs-2-seconds-on-rdp/6709/6 "2023-10-21T00:58:01Z")

</div>

Maybe the problem is that it takes too long to decide. Either way, a lot of devs use a “fast remove” function instead of the built-in REMOVE() because of the slowness.

A REMOVE(\*QUEUE pFileQueue) would be useful. It could create a big string of filenames with the null delimiter, then call SHFileOperation one time.

---

<div class="post-metadata">

**Author:** ![mriffey](https://clarionhub.com/letter_avatar_proxy/v4/letter/m/cab0a1/32.png) [@mriffey](https://clarionhub.com/u/mriffey)\
**Post date:** [October 21, 2023, 6:00pm UTC](https://clarionhub.com/t/remove-file-vs-ds-deletefile-file-22-seconds-vs-2-seconds-on-rdp/6709/7 "2023-10-21T18:00:23Z")

</div>

The delete speed discussion was in this thread: [Test if Close(Report) is SLOW on your System? – Mine 100x slower than C6 - #7 by CarlBarnes](https://clarionhub.com/t/test-if-close-report-is-slow-on-your-system-mine-100x-slower-than-c6/4491/7)

---

<div class="post-metadata">

**Author:** ![jslarve](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jslarve](https://clarionhub.com/u/jslarve)\
**Post date:** [October 21, 2023, 9:06pm UTC](https://clarionhub.com/t/remove-file-vs-ds-deletefile-file-22-seconds-vs-2-seconds-on-rdp/6709/8 "2023-10-21T21:06:49Z")

</div>

Thanks Mark. I knew it was Carl, but thought it was on github
