首页 > 解决方案 > 如何用我的程序资源中的文件覆盖特定文件夹中的文件

问题描述

我的程序资源中有一个名为“something.a 二进制扩展名”“不是 txt 扩展名”的文件,并且同一个文件存在于另一个文件夹中,并且也名为“Something.a 二进制扩展名”。

我想复制我的资源文件并用它替换现有文件。

我的程序有 2 个button控件,一个用于浏览以获取pathfrom OpenFileDialog1,另一个用于复制我的资源文件并用它替换现有文件“具有相同名称”,以及 1 个TextBox用于显示path.

节目照片

我的程序有一个清单文件以管理员身份运行level="highestAvailable

我使用这段代码:

Public Class Form1
    Dim Path_of_folder As String
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnBrowse.Click
        'getting the path
        OpenFileDialog1.ValidateNames = False
        OpenFileDialog1.CheckFileExists = False
        OpenFileDialog1.CheckPathExists = True
        OpenFileDialog1.FileName = "somthing.exe"
        OpenFileDialog1.ShowDialog()
        TextBox1.Text = System.IO.Path.GetFullPath(OpenFileDialog1.FileName)
        TextBox1.Text = TextBox1.Text.Replace("somthing.exe", "").Trim()
        Path_of_folder = TextBox1.Text 'we got the path
    End Sub

    Private Sub BtnCopy_Click(sender As Object, e As EventArgs) Handles BtnCopy.Click
        FileCopy(My.Resources.somthing, Path_of_folder) ' this got Error when i use it,  but the program can Run 
    End Sub
End Class

标签: vb.netfilepathcopying

解决方案


推荐阅读