背景:
今天碰到这样一种情况,我在删除这个VS文件夹下的.user文件时,不小心把.vcxproj.filters也删除了。当然为什么删.user呢,因为换电脑了。
删除之后,我发现:我的解决方案目录变成这样了:
对比一下,以前的我的是这样的:
然后,有那么一刹那,我慌了,虽然这个东西对于开发没有什么影响,但是我觉得看着很不舒服,找起源文件和头文件还有ui文件来,很不好找,我不喜欢这样。
先说一下,我找了半天,他们所处的情况都是这样的:
首先,我的.vcxproj.filters 文件没有被动过,然后我点击这个按钮就可以解决问题:
但是我的不是啊,我把文件删了啊。
准备开始:
于是,我在想,如何进行灾后重建啊:
第一步,先看一下这个例子:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="MFCApplication1.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MFCApplication1Dlg.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Resource.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="MFCApplication1.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MFCApplication1Dlg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="MFCApplication1.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="res\MFCApplication1.rc2">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Image Include="res\MFCApplication1.ico">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
</Project>
乍一看,这有点乱啊!
别慌!慢慢来:
1、打开我的.vcxproj.filters 文件(先将VS关闭)
将下面这行语句复制到文件中:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Form Files">
<UniqueIdentifier>{99349809-55BA-4b9d-BF79-8FDBB0286EB3}</UniqueIdentifier>
<Extensions>ui</Extensions>
</Filter>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}</UniqueIdentifier>
<Extensions>qrc;*</Extensions>
<ParseFiles>false</ParseFiles>
</Filter>
</ItemGroup>
</Project>
2、打开VS
这个时候你关闭文件夹,它会提示你保存,那么你再打开.vcxproj.filters文件:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Form Files">
<UniqueIdentifier>{99349809-55BA-4b9d-BF79-8FDBB0286EB3}</UniqueIdentifier>
<Extensions>ui</Extensions>
</Filter>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}</UniqueIdentifier>
<Extensions>qrc;*</Extensions>
<ParseFiles>false</ParseFiles>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="myQGraphicsView.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="myQGraphicsViewB.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="myQTwidget.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="keyboardEvent.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="myStaticalTable.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="reCheck.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="keyboardEvent.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="reCheck.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<QtMoc Include="myQTwidget.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="myQGraphicsView.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="myQGraphicsViewB.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="myStaticalTable.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="reCheck.h">
<Filter>Header Files</Filter>
</QtMoc>
</ItemGroup>
<ItemGroup>
<QtRcc Include="reCheck.qrc">
<Filter>Resource Files</Filter>
</QtRcc>
<QtRcc Include="Res.qrc">
<Filter>Resource Files</Filter>
</QtRcc>
</ItemGroup>
<ItemGroup>
<QtUic Include="myQTgraphicsView.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtUic Include="myQTwidget.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtUic Include="myStaticalTable.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtUic Include="reCheck.ui">
<Filter>Form Files</Filter>
</QtUic>
</ItemGroup>
<ItemGroup>
<None Include="cpp.hint" />
</ItemGroup>
</Project>
你会发现多了很多的刚才选中的.ui、.h、.cpp都添加到里面了,完成。
灾后重建工作圆满完成!!!!