set IDE file as ReadOnly

L

lausivcid

Hi,

My project include reading XML files, I would like to set ReadOnly
via a Keyboard Hot Key combination on the test XML files when I open
them in the IDE. Is there an IDE Command I can setup with a Hot
Key combination?

Thanks,
Lausivcip
 
P

Peter Macej

I haven't found any VS command that can do it. You can however write
simple macro which will toggle read-only state of active document:
''' <summary>
''' Toggles the read-only flag of active open document in the IDE.
''' </summary>
Sub ToggleReadonly()
Dim filename As String
Dim attributes As System.IO.FileAttributes

filename = DTE.ActiveDocument.FullName
attributes = System.IO.File.GetAttributes(filename)
' negate read-only
attributes = attributes Xor IO.FileAttributes.ReadOnly
System.IO.File.SetAttributes(filename, attributes)
End Sub

1. Create this macro, see http://www.helixoft.com/blog/archives/6 if you
don't know how.
2. Assign a keybord shortcut to it, see
http://www.helixoft.com/blog/archives/8
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top