2014年5月16日 星期五

內崁exe資源檔要如何開啟使用

參考1:
Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Click
Dim tobjStream As IO.Stream = Me.GetType.Assembly.GetManifestResourceStream("resourcesample2.License.txt")
Dim tobjStreamReader As New IO.StreamReader(tobjStream, System.Text.Encoding.Default)
Dim tstrLicense As String = tobjStreamReader.ReadToEnd
'如果是图象就可以使用dim tobjBMP as new bmp(tobjstrem)的方法直接得到资源内容
MessageBox.Show(tstrLicense)'显示刚才读得的结果
End Sub

參考2
  string apName = "ClaimLicense.Manifest"; // WindowsApplication6 corresponds to Default Namespace in your project settings.
System.IO.Stream strm = null;
strm = this.GetType().Assembly.GetManifestResourceStream(apName);
byte[] buf = new byte[strm.Length];
strm.Read(buf, 0, buf.Length);
apName = "AAA.EXE";
FileStream fs = new FileStream(apName,FileMode.Create, FileAccess.Write);
fs.Write(buf, 0, buf.Length);
fs.Close();
strm.Close();

沒有留言:

張貼留言