经常需要打开VS中一些项目文件的目录,但由于VS没有自带此功能,所以必须从我的电脑慢慢一层层的打开,很是麻烦。今天想到了一种快捷办法,给大家共享一下。(VS2005提供了在文件上面的卡片中按右键可以打开文件目录,但需要先打开此文件。)
“解决方案资源管理器”中,在一个文件上按右键,选择“打开方式...”,点击按钮“添加...”,程序名中输入:“explorer /select,”,注意后面有个逗号,“友好名称”自己随便输,我写的是“打开文件目录”,点“确定”,会提示文件名不存在,不管它,点“否”。
后面的你应该就知道了,在想打开某个文件目录时,在文件上按右键-->“打开方式...”-->“打开文件目录”就可以打开此文件的目录,并定位到此文件上。
----发现在2005中不行,2005中需要自己写个程序(然后添加此程序就行了):
//
把除System外的所有引用都删除,把Form1也删除,只需要Program的Main方法
static void Main( string [] args)
{
if (args != null || args.Length != 0 )
{
string pathName = args[ 0 ];
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = " explorer " ;
p.StartInfo.Arguments = " /select, " + pathName;
p.StartInfo.CreateNoWindow = false ;
p.StartInfo.UseShellExecute = true ;
p.Start();
p.Dispose();
}
}
static void Main( string [] args)
{
if (args != null || args.Length != 0 )
{
string pathName = args[ 0 ];
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = " explorer " ;
p.StartInfo.Arguments = " /select, " + pathName;
p.StartInfo.CreateNoWindow = false ;
p.StartInfo.UseShellExecute = true ;
p.Start();
p.Dispose();
}
}