请问作为资源文件的xml文件在程序运行中可否编辑?

DevinXie 2010-06-03 05:17:27
我把一个xml文件作为资源文件添加进项目了,【生成操作】选择的是【嵌入的资源】,这样一来,我可以通过下面的方式在程序运行过程中读取到这个xml文件

Dim thisExe As System.Reflection.Assembly
thisExe = System.Reflection.Assembly.GetExecutingAssembly()
Dim xmlFile As System.IO.Stream
xmlFile = thisExe.GetManifestResourceStream("xxxx.ItemList.xml")

现在的问题是:是否可以在程序运行时,是否有什么方法可以编辑并把结果回写回去?
...全文
71 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
hitlcyu19 2010-06-04
  • 打赏
  • 举报
回复
不能吧
沐NeMo 2010-06-04
  • 打赏
  • 举报
回复
写到exe里面的资源文件是不可以改变的。如果是放在exe的同一个文件夹里面的辅助文件,就可以改。
只在此山中 2010-06-04
  • 打赏
  • 举报
回复
嵌入的资源就生成到exe文件了,编辑并回写,那exe文件都要变,一般不行,也没必要。
参考,读写资源文件:
2008-02-19 16:48Private Sub btnBulid_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBulid.Click
Try
Dim rw As New Resources.ResourceWriter("res.resources")
With rw
.AddResource("100_5062", Image.FromFile("d:\My Documents\My Pictures\100_5062.jpg"))
'...
.AddResource("Name", "张三")
.Generate()
.Close()
End With

Catch ex As Exception
MsgBox("btnBulid_Click:" + ex.Message, MsgBoxStyle.Information, Me.Text)
End Try

End Sub

Private Sub btnRead_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRead.Click
Try

Dim reader As New Resources.ResourceReader("res.resources")
Dim en As IDictionaryEnumerator = reader.GetEnumerator()

While en.MoveNext()
If en.Key = "100_5062" Then
Me.PictureBox1.Image = CType(en.Value, Image)
Exit While
End If
End While
reader.Close()

Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

16,553

社区成员

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

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