读取VS2005项目文件vbproj

tianxia08 2010-08-10 10:35:16
应该是xml格式吧?!

我想知道如何读取所有窗体文件(.resx结尾的),xmlDoc.SelectNodes("Project")(0)取不到东西,所以就不能继续了
另外,VS2010与2005项目文件的格式是不是一样的?


<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<EmbeddedResource Include="Form1.resx">
<SubType>Designer</SubType>
<DependentUpon>Form1.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="My Project\Resources.resx">
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
<CustomToolNamespace>My.Resources</CustomToolNamespace>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="My Project\Application.myapp">
<Generator>MyApplicationCodeGenerator</Generator>
<LastGenOutput>Application.Designer.vb</LastGenOutput>
</None>
<None Include="My Project\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<CustomToolNamespace>My</CustomToolNamespace>
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
</None>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
...全文
104 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
tianxia08 2010-08-10
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 wuyazhe 的回复:]
VB.NET code

Dim xml As String = File.ReadAllText("Form1.Designer.vb")
Dim mc As MatchCollection = Regex.Matches(xml, "(?<=Friend WithEvents )\b\w+\b(?= As)")
For Each m As Match In mc
'm.Val……
[/Quote]
多谢!
兔子-顾问 2010-08-10
  • 打赏
  • 举报
回复

Dim xml As String = File.ReadAllText("Form1.Designer.vb")
Dim mc As MatchCollection = Regex.Matches(xml, "(?<=Friend WithEvents )\b\w+\b(?= As)")
For Each m As Match In mc
'm.Value就是每个变量的名字
Next
tianxia08 2010-08-10
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 wuyazhe 的回复:]
是的。那你是要变量名呢还是要类型呢?还是如何
[/Quote]
控件名称,比如Button1,Label1这些!
兔子-顾问 2010-08-10
  • 打赏
  • 举报
回复
是的。那你是要变量名呢还是要类型呢?还是如何
tianxia08 2010-08-10
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 wuyazhe 的回复:]
这个不保存在vbproj中吧,要找designer.vb文件。
[/Quote]
对呀
查找Controls.Add好象不准确,好象要查找Friend WithEvents
兔子-顾问 2010-08-10
  • 打赏
  • 举报
回复
这个不保存在vbproj中吧,要找designer.vb文件。
tianxia08 2010-08-10
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 wuyazhe 的回复:]
如果想得到文件名:

VB.NET code
Dim xml As String = File.ReadAllText("你的项目.vbproj")
Dim mc As MatchCollection = Regex.Matches(xml, "(?<=<EmbeddedResource[^""]+"")[^""]+")
For Each ……
[/Quote]
非常感谢!
请再帮个忙,不懂正则,在Form1.Designer.vb中如何读取所有的控件名称呢?
兔子-顾问 2010-08-10
  • 打赏
  • 举报
回复
如果想得到文件名:
        Dim xml As String = File.ReadAllText("你的项目.vbproj")
Dim mc As MatchCollection = Regex.Matches(xml, "(?<=<EmbeddedResource[^""]+"")[^""]+")
For Each m As Match In mc
'm.Value就是资源文件名
Next

16,722

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧