NTFS.File.Delete Exception

Jul 22, 2011 at 9:01 AM

Hi Ken,

I seem to have found in problem with Ntfs.File.Delete.

Sometimes it throws the exception: Collection was modified; enumeration operation may not execute

I don't know why it happens on some windows servers and not others.

I have traced it down to this:

 

            foreach (var attr in _attributes)

            {

                attr.GetDataBuffer().SetCapacity(0);

            }

 

I have replaced with:

 

            for (int i = _attributes.Count - 1; i >= 0; i--)

            {

                NtfsAttribute attr = (NtfsAttribute)_attributes[i];

                attr.GetDataBuffer().SetCapacity(0);

            }

 

is this ok?

Thanks,

Mark

Coordinator
Jul 24, 2011 at 8:06 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.