怎样读取一个文本文件(已经成为程序的一个资源文件)呢?解决思路
怎样读取一个文本文件(已经成为程序的一个资源文件)呢?
有一个文本文件,通过设置,使它成为vb.net程序的一个资源文件。因为文件已经成为程序的一个资源文件,那我在程序运行时,怎样读取这一个文本文件呢?
------解决方案--------------------
定义一个方法:
Public Function GetResource(ByVal strname As String) As System.IO.Stream
Dim strTitle As String = "CLASS " '名前空间
Return System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream(strTitle & strname)
End Function
strname 是资源文件的文件名
------解决方案--------------------
My.Computer.FileSystem.ReadAllText(path)
有一个文本文件,通过设置,使它成为vb.net程序的一个资源文件。因为文件已经成为程序的一个资源文件,那我在程序运行时,怎样读取这一个文本文件呢?
------解决方案--------------------
定义一个方法:
Public Function GetResource(ByVal strname As String) As System.IO.Stream
Dim strTitle As String = "CLASS " '名前空间
Return System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream(strTitle & strname)
End Function
strname 是资源文件的文件名
------解决方案--------------------
My.Computer.FileSystem.ReadAllText(path)