You don't have access to the local machine store as read and write but you can access it as readonly so you can add CERT_STORE_READONLY_FLAG to enable that so your code will look like this:
...