How to delete a Layer

How to delete a layer in psd file?I didn’t find it in the method provided by psd. Is it not supported?

@zyyxiage

Can you please provide more details about the method you are using to delete a layer in the PSD file?

image.png (1.8 KB)

As shown in the picture, I want to delete the B layer。

@zyyxiage please try using LINQ. It’s most comfy way for layers set editing for .NET:

        using (var psdImage = (PsdImage)Image.Load(srcFile))
        {
            var layers = new List<Layer>(psdImage.Layers);
            layers.RemoveAll(it => it.DisplayName == "B");
            psdImage.Layers = layers.ToArray();
        }