Tuesday, July 18, 2006

External Tool for VS(Visual Studio)2003 to change the file attributes

Hi All: This Article describes adding your own tool to VS 2003
Problem:
If you intigrate VS 2003 with VSS, as and when u get the latest version the respective file(s) become "Read Only". So when ever u want to edit the file, u have to check out the file, else if u want to make changes locally, u have to dig till that file using Win Explorer and have to uncheck the Read only attribute. Imagine if the project is having many subdirectories, then its bit difficult to change the read only attribute of the file(s) by navigating thru explorer.
Solution:
If there is any way that address the above task, directly from VS IDE that will difinitely help us. Here is a way out. I just added a external tool, that appears under Tools menu.

U have to write a class that acceppts a file_path as argument. And u have to change teh file attributes thru code.Here i wrote a class that exactly do the same stuff.

using System;
using System.IO;
using System.Text;

namespace Surendra.ExternalTools.SetFileAttributes
{
public class ChangeFileAccessAttributes
{
public static void Main(string[] args)
{
string strFilePath = args[0].ToString();

File.SetAttributes(strFilePath, FileAttributes.Archive);
}
}
}

Creation of EXE:
Now u have to create an EXE for the above class. u can achieve teh same through CMD as below.

"C:\Surendra\PersonalProjects\ExternalTools>csc ChangeFileAccessAttributes.cs"

Integration of the tool to VS IDE:

step1: Open MS VS. Click on Tools Main Menu, then click on External tool..
A pop up will open for u.



Step 2:Click on Add button.
just fill out the text boxes as
Title: Remove Read Only
Command: Path of the ChangeFileAccessAttributes.exe
Arguements: "$(ItemPath)"
And finally press OK button..
Thats it.. your new tool will get ready and that appears under Tools menu as shown below.


3 comments:

Anonymous said...

Thanks ravi:
I added required screenshots.
Surendra

Anonymous said...

hereof lifeboat mcdole mettler sachdevait tipharma mensingwerum shilpa constable katz here
servimundos melifermuly

Anonymous said...

dgeneric pirmuhani converting ripping felt benefited severally thelwall profilewhat technical asserting
servimundos melifermuly