Eugene
Eugene

Reputation: 11535

Prevent .net program from writing to disk

How do I prevent my .net (C#) program from ever writing to disk?

Edit: There's a FileIOPermissionAttribute for anyone curious. This codeproject also shows a way.

Upvotes: 2

Views: 104

Answers (2)

Marc Gravell
Marc Gravell

Reputation: 1062492

You can use caspol to ensure that the exe is not executed with "full trust", and limit the trust excluding that permission (FileIOPermission). However, if the exe is not designed and tested to run without full trust, it could completely fail to do anything.

Upvotes: 2

Toto
Toto

Reputation: 56

You can run it with an account that is not authorized to write to disk.

Upvotes: 2

Related Questions