vb.net 释放项目内文件

百度搜索了一大堆,发现大部分说得都不够详细,于是只好自己记录下了。

  1. 添加文件
    菜单:【项目】>【添加现有项】,在弹出的对话框内选择相应文件(比如:Loading.swf)。
  2. 设置文件属性
    在【解决方案资源管理器】内,找到刚添加的文件Loading.swf,右击选择【属性】
    将其【生成操作】一栏参数设为【嵌入的资源】
  3. 添加代码
    Public Sub 释放文件(ByVal 文件名 As String, ByVal 路径 As String)
          Try
                Dim 文件流 As IO.Stream = Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream(My.Application.Info.AssemblyName + "." + 文件名)   '获取资源文件的流
                Dim 文件内容(文件流.Length - 1) As Byte  '定义数组
                Dim 新文件 As New IO.FileStream(路径 + "\" + 文件名, IO.FileMode.OpenOrCreate)   '创建文件
                文件流.Read(文件内容, 0, 文件内容.Length)
                新文件.Write(文件内容, 0, 文件内容.Length)
                文件流.Close()
                新文件.Close()
          Catch ex As System.IO.D
    irectoryNotFoundException
                MessageBox.Show("未找到以下路径:" + 路径, "错误", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error)
          Catch ex As System.NullReferenceException
                MessageBox.Show("未发现资源文件:" + 文件名, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error)
          Catch ex As exception
                Msgbox(ex.message)
          End Try
    End Sub
  4. 在需要的地方调用上述函数即可。如释放文件(“Loading.swf”, 存储位置)注:区分大小写,且不管该文件是否放在某一特定文件夹内都应只写文件名(C#需包含具体文件夹名)。

案例下载:链接: http://pan.baidu.com/s/1sjoFgiL 密码: 3dn6

另请参阅:http://www.cnblogs.com/chiname/articles/133034.html

Intel? 64 and IA-32 Architectures Software Developer’s Manual

【PDF】Intel? 64 and IA-32 Architectures Software Developer’s Manual Combined Volumes: 1, 2A, 2B, 2C, 3A, 3B and 3C
Intel? 64 and IA-32 Architectures Software Developer’s Manual Combined Volumes: 1, 2A, 2B, 2C, 3A, 3B and 3C

下载地址:http://pan.baidu.com/s/1sj7AjTF

来源页面:http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html

应该没有比这个更全的开发手册了吧~ 学汇编必备。