Visual Studio - Open a file as read-only

jprg
06-01-2011, 01:08 PM
Hi,

In Visual Studio, how can I open a source file (from another project) in read-only mode? I want to copy some code from it, but I don't want to modify it by mistake.
I don't want to change the file's attributes to read-only, as I will not be able to work on it later, unless I clear read-only. I hope there is a better way.

Thanks.

AtmaWeapon
06-01-2011, 01:55 PM
I don't think there's a way to do this. If you are using source control, that will help you not modify the file, and even if you accidentally modify it you can undo the modifications.

If you add the file to your project, by default Visual Studio will make a copy of the file in your project's tree. That's a rudimentary way to make sure you don't accidentally modify the original.

In general, if you're sharing some code between projects it's best to factor it into a class and let each project have a copy of the file.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum