# How do I get a file Resource length?

**URL:** <https://forum.xojo.com/t/how-do-i-get-a-file-resource-length/88157>\
**Category:** macOS\
**Created:** [April 26, 2026, 2:02pm UTC](https://forum.xojo.com/t/how-do-i-get-a-file-resource-length/88157 "2026-04-26T14:02:28Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [April 26, 2026, 2:02pm UTC](https://forum.xojo.com/t/how-do-i-get-a-file-resource-length/88157/1 "2026-04-26T14:02:28Z")

</div>

The subject says nearly all.

More details:  
The file name is Icon (followed by a Return) and is created by macOS (I ask it to do that): it is a custom icon for the Finder (the Finder use it to replace the default value).

Usually they are Filder custom icons (icon of a standard Finder folder + either a Book, Magazine cover, LP/CD/DVD… cover, a red cross for health documents… (you understand what I mean)

For unknow reasons, sometimes they appears (lost their invisibility) and so I use my hex dump utility (a simple button to set the Visibility - on or OFF - below the screen shot.

 ![image](https://forum.xojo.com/uploads/default/original/3X/6/b/6bcbd94d1d49962ce673dc362ad4d8bd37d6c934.jpeg)  
As you see the file have a legth of 0 Bytes (in the data fork), and unknow size in the Resource fork: I never implemented that.

The documentation does not shows a command to get the file Resource length (it does not show how to Open that file too).

How to get a file Resource Length ?  
How load a file Resource ?  
(image in this case, but who knows what exists inside macOS (or some applications ?)

A folder contents on the left with a selected image that is displayed on the right…

That folder have a custom icon (named `Popeye - macos - icon.png` in the screen shot). macOS use the data stored in the file Icon+CR…)

 ![image](https://forum.xojo.com/uploads/default/original/3X/e/2/e25a9f65aa2c9cb4c991f447c452d955d6705e5a.jpeg)

---

<div class="post-metadata">

**Author:** ![Eric\_Pousse](https://forum.xojo.com/user_avatar/forum.xojo.com/eric_pousse/32/1604_2.png) [@Eric\_Pousse](https://forum.xojo.com/u/Eric_Pousse)\
**Post date:** [April 26, 2026, 2:45pm UTC](https://forum.xojo.com/t/how-do-i-get-a-file-resource-length/88157/2 "2026-04-26T14:45:01Z")

</div>

I think that there is no more resource in files.

That was before…

---

<div class="post-metadata">

**Author:** ![Jeff\_Tullin](https://forum.xojo.com/user_avatar/forum.xojo.com/jeff_tullin/32/693_2.png) [@Jeff\_Tullin](https://forum.xojo.com/u/Jeff_Tullin)\
**Post date:** [April 26, 2026, 3:12pm UTC](https://forum.xojo.com/t/how-do-i-get-a-file-resource-length/88157/3 "2026-04-26T15:12:09Z")

</div>

If you apply a _custom_ icon to a file, you do still get a hidden resource file that holds the preview bitmap.

Some zipping processes retain these files, some do not.

So if you compress without the resource file, and uncompress elsewhere, there will be no special preview. (This may have nothing to do with your post, but its hard to know what you are asking)

To apply a custom icon in MacOs, I use a monkeybread/ Macos wrapped function, SetIcon

```auto
dim img as NSImageMBS

img=new NSImageMBS(p1)

if NSWorkspaceMBS.setIcon(img,f,0) then

```

To get the icon back, I use IconMBS which is an extension of folderitem

`f.IconMBS(50)`

I don’t know for sure how to get the filesize of the resource,

unless it happens to be the length of the file named the same way as yours, but with a \_ prefix

like

Myfile.jpg

and

\_Myfile.jpg

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [April 26, 2026, 4:39pm UTC](https://forum.xojo.com/t/how-do-i-get-a-file-resource-length/88157/4 "2026-04-26T16:39:31Z")

</div>

Thank you Eric for trying to help.

> [@Eric\_Pousse](#):
>
> I think that there is no more resource in files.

Read correctly my question AND “Yes Man, There are still files with resources written in it by macOS 26.4.1:

 ![image](https://forum.xojo.com/uploads/default/original/3X/8/8/885c3ca4b3cdaf5bd4a229246b314ea713b56873.jpeg)

Of course, if you do not set a custom icon to a Folder, you will never have one (I think, biut not 100% sure). And since that file is invisible (as I wrote in my orginal post), you have to find a way to see that file.

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [April 26, 2026, 4:49pm UTC](https://forum.xojo.com/t/how-do-i-get-a-file-resource-length/88157/5 "2026-04-26T16:49:10Z")

</div>

> [@Jeff\_Tullin](#):
>
> \_Myfile.jpg

As you noticed, this kind of file appears when you move a folder to Windows; Windows creates them, I think they are links (alias in macOS “language”) because they are not images / I do not checked what is inside these files to be sure, but their length says the contents is not the image we will find in `Myfile.jpg`.

I have found 93 files who starts with an underscore (\_) character including some from Xojo, but these are not related to what you wrote.

This is what I want to do:

> [@Emile\_Schwarz](#):
>
> How to get a file Resource Length ?  
> How load a file Resource ?

BTW: this is the information window for a File With a Resource Fork holding a (Custom Folder) Icon:

 ![image](https://forum.xojo.com/uploads/default/original/3X/9/9/99e4a689a3085a448545700d955eac8cc4a9420b.jpeg)

This file have a length: 191,453Bytes and is usually invisible (look at `FolderItem.Visible` in the Documentation for an example on how to deal with `FolderItem.Visible`:

```auto
Var f As FolderItem = FolderItem.ShowOpenFileDialog("????")

If f.Visible Then
  MessageBox(f.DisplayName)
Else
  MessageBox("The FolderItem is not visible.")
End If

```

Adding `f.Visible = True` will display the invisible file in the Finder.

Copy an image, (photo, artwork, screen shot)…  
Add a dummy Folder,  
set Get Info from the Finder Menu Bar,  
Click in the Folder Icon on the top left of the Info Window,  
Paste.

And you get both a new icon and the invisible one.

That is if you are curious enough to check what I wrote (and understand me).

---

<div class="post-metadata">

**Author:** ![Jeff\_Tullin](https://forum.xojo.com/user_avatar/forum.xojo.com/jeff_tullin/32/693_2.png) [@Jeff\_Tullin](https://forum.xojo.com/u/Jeff_Tullin)\
**Post date:** [April 26, 2026, 5:46pm UTC](https://forum.xojo.com/t/how-do-i-get-a-file-resource-length/88157/6 "2026-04-26T17:46:16Z")

</div>

> Windows creates them,

Are you sure?

If you copy a folder from Mac to a USB stick, they are there. They show up in Windows even if the USB stick is read only. It sees them, where MacOs hides them from you.

> _their length says the contents is not the image we will find in `Myfile.jpg`._

They probably hold a small thumbnail image, rather than the entire myfile.jpg, surely?

Your original file might be thousands of pixels in size. Thumbnail previews don’t need to be anywhere near as large. (If it held the same data as the original, it wouldnt need to exist at all.)

Most of this is ‘guesswork’ I confess - I don’t have time to go research it right now.

---

<div class="post-metadata">

**Author:** ![Eric\_Williams](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/ecccb3/32.png) [@Eric\_Williams](https://forum.xojo.com/u/Eric_Williams)\
**Post date:** [April 26, 2026, 8:13pm UTC](https://forum.xojo.com/t/how-do-i-get-a-file-resource-length/88157/7 "2026-04-26T20:13:39Z")

</div>

> [@Emile\_Schwarz](#):
>
> Read correctly my question AND “Yes Man, There are still files with resources written in it by macOS 26.4.1:

Resource FORKS have been deprecated for many, many years and not used by any modern software even if the file system still supports them. Apps that store metadata - for example, Finder icons - that would previously have landed in a resource fork instead often use invisible files such as .DS\_Store to do so.

So there’s no way to get the size of a resource fork because they simply don’t exist anymore. That’s the answer.

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [April 26, 2026, 10:06pm UTC](https://forum.xojo.com/t/how-do-i-get-a-file-resource-length/88157/8 "2026-04-26T22:06:15Z")

</div>

No Eric Williams, I disagree and I gave you a way to check that by yourself IN THE CASE I DOCUMENTED.

Is ther other cases ? (I talk about the Icon+\cr system file) I do not know. Other ways to add an icon to an image file that represent that image still exist (in the past, do not know if this is still the case) and I do not know how to do that (in special meta data ?).

.DS\_Store never stored custom icons set in the Finder.

Remember: a Finder Icon is 1024 x 1024 x 32 Bits (32 bits: I think) Icon and so his size is in tune with that.

I hope Michael read that (you too can check what I wrote to be sure you are right - that is not the case, but check and you will know).

I have done my duty, and if you prefer to stay on your position, it is your choice.

BTW: if you can prove that I am wrong, feel free to explain how I am able to check I am really wrong.

For the record, I use a MacBookPro 13" m1. So I run Tahoe ARM not a macOS Wintel Version.

Just in case, I add the code below to a test project and here’s the answer:

 ![image](https://forum.xojo.com/uploads/default/original/3X/f/b/fbc69728f5f4b2bf24bd5164c018309917c875f1.png)

Code:

Size of the file in Get Info:  
Var f As FolderItem = FolderItem.ShowOpenFileDialog(“???”)

If f \<\> Nil Then  
MessageBox(f.DisplayName + " size length: " + f.Length.ToString)  
End If

Finder in list mode:  
 ![image](https://forum.xojo.com/uploads/default/optimized/3X/5/b/5b24a089663740e7ede10abf334fbfbdfa72eb33_2_690x24.png)

Get Info for the icon+CR file:

 ![image](https://forum.xojo.com/uploads/default/original/3X/7/7/778a84b9818744d91046d1d2bef8a6d1103babd6.jpeg)

I hope this is clear. It’s late here (5 mins past midnight).

---

<div class="post-metadata">

**Author:** ![Michael\_Hußmann](https://forum.xojo.com/user_avatar/forum.xojo.com/michael_hu%C3%9Fmann/32/438_2.png) [@Michael\_Hußmann](https://forum.xojo.com/u/Michael_Hu%C3%9Fmann)\
**Post date:** [April 26, 2026, 10:22pm UTC](https://forum.xojo.com/t/how-do-i-get-a-file-resource-length/88157/9 "2026-04-26T22:22:44Z")

</div>

It is true that macOS to this day uses resource forks in a few places even though Apple has tried to make it appear they were gone for good. I’ve always had a soft spot for resource forks and was sad when Apple decided to do without (many years ago) but this appears to be a case of ‘Do as I say, not do as I do’ – despite resource forks being officially declared extinct they are still in active use.

---

<div class="post-metadata">

**Author:** ![Eric\_Williams](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/ecccb3/32.png) [@Eric\_Williams](https://forum.xojo.com/u/Eric_Williams)\
**Post date:** [April 26, 2026, 11:03pm UTC](https://forum.xojo.com/t/how-do-i-get-a-file-resource-length/88157/10 "2026-04-26T23:03:26Z")

</div>

> [@Emile\_Schwarz](#):
>
> BTW: if you can prove that I am wrong, feel free to explain how I am able to check I am really wrong.

Since you asked…

A quick search revealed that for folders, the Finder stores custom icons as data in an extended attribute attached to that Icon^M file. You can see thusly:

```auto
Erics-MacBook-Pro:folder with custom icnon eric.w$ ls -l@

total 1832

-rw-r--r--@ 1 eric.w staff 0 Apr 26 15:51 Icon?
	com.apple.FinderInfo	32
	com.apple.ResourceFork	937348

```

Yes, the data is keyed as “ResourceFork” and might even be structured in a similar way but it is NOT stored in a fork. It is stored as an extended attribute, which is attached to the file but not part of its data - that’s why you don’t see it in any of the conventional Folderitem.Length methods. You can see this data by doing this:

```auto
Erics-MacBook-Pro:folder with custom icon eric.w$ xattr -plx com.apple.ResourceFork Icon^M

com.apple.ResourceFork:

00000000 00 00 01 00 00 0E 4D 52 00 0E 4C 52 00 00 00 32 |......MR..LR...2|
00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

```

I’m using the ‘x’ option to get the data as hex - otherwise it doesn’t show due to all the 0 characters in there.

There appears to be no reason the com.apple.ResourceFork data couldn’t be attached to the folder directly; folders and even symbolic links can accept extended attributes. My hunch is that by stuffing the data into the Icon^M file, it maintains compatibility with older MacOS systems and possibly makes moving files between platforms easier.

---

<div class="post-metadata">

**Author:** ![Arnaud\_N](https://forum.xojo.com/user_avatar/forum.xojo.com/arnaud_n/32/21824_2.png) [@Arnaud\_N](https://forum.xojo.com/u/Arnaud_N)\
**Post date:** [April 27, 2026, 6:35am UTC](https://forum.xojo.com/t/how-do-i-get-a-file-resource-length/88157/11 "2026-04-27T06:35:27Z")

</div>

It may be worth to mention that the extended attribute “com.apple.ResourceFork” is the “new” way to store resource forks. The separate data stream that used to exist has been replaced by this extended attribute.  
I can’t say whether the current OS still supports alternate data streams for files on APFS or HFS+, though… 🤔

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [April 27, 2026, 9:31am UTC](https://forum.xojo.com/t/how-do-i-get-a-file-resource-length/88157/12 "2026-04-27T09:31:49Z")

</div>

I’d like to point to some things in [MBS Xojo Plugins](https://www.monkeybreadsoftware.de/xojo/), if you use our plugins:

- We have [LogicalFileResLengthMBS](https://www.monkeybreadsoftware.net/folderitem-logicalfilereslengthmbs.shtml#l3) property in folderitem class.
- You can use OpenAsResStream in [LargeBinaryStreamMBS](https://www.monkeybreadsoftware.net/class-largebinarystreammbs.shtml) class to open the resource fork as binary data and read it (or [ResStreamMBS](https://www.monkeybreadsoftware.net/class-resstreammbs.shtml) class). But to actually use resources, you’d use [ResourceForkMBS](https://www.monkeybreadsoftware.net/class-resourceforkmbs.shtml) class instead.
- You can use [DirectorySizeMBS](https://www.monkeybreadsoftware.net/class-directorysizembs.shtml) class to check
- Since macOS X the resource fork is stored as an extended attribute, so you can modify it with [ExtendedAttributesMBS](https://www.monkeybreadsoftware.net/module-extendedattributesmbs.shtml) module.
- And to remove it, you can use [DeleteResourceForkMBS](https://www.monkeybreadsoftware.net/folderitem-deleteresourceforkmbs.shtml#d5) method in FolderItem class.

But for adding icons, I recommend to use high level functions like setIcon() in [NSWorkspaceMBS](https://www.monkeybreadsoftware.net/class-nsworkspacembs.shtml) class.

---

<div class="post-metadata">

**Author:** ![Eric\_Williams](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/ecccb3/32.png) [@Eric\_Williams](https://forum.xojo.com/u/Eric_Williams)\
**Post date:** [April 27, 2026, 1:26pm UTC](https://forum.xojo.com/t/how-do-i-get-a-file-resource-length/88157/13 "2026-04-27T13:26:06Z")

</div>

> [@Arnaud\_N](#):
>
> I can’t say whether the current OS still supports alternate data streams for files on APFS or HFS+, though

It does. They’re implemented a little differently from how HFS+ did it but they work.
