vb.net - 如何用我的程序资源中的文件覆盖特定文件夹中的文件
问题描述
我的程序资源中有一个名为“something.a 二进制扩展名”“不是 txt 扩展名”的文件,并且同一个文件存在于另一个文件夹中,并且也名为“Something.a 二进制扩展名”。
我想复制我的资源文件并用它替换现有文件。
我的程序有 2 个button
控件,一个用于浏览以获取path
from 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
解决方案
推荐阅读
- google-cloud-platform - Cloud SQL 代理 - 消息:权限不足
- android - 从 Android 模拟器连接到本地 asp.net Web 服务器
- pytorch - 使用不同长度的批次进行 PyTorch 训练?
- c++ - 如何在 C++ 中存储一组整数值
- perforce - Perforce&Swarm:提交更改后文件从工作区中删除
- arduino - 如何使用 Google Drive REST API v3 执行分段上传
- javascript - 从 node.js 应用程序到达 gmail 时,长链接被破坏
- git - 当我尝试使用 SSH 密钥第一次访问时,Git 客户端询问密码
- javascript - Mocha async afterEach 钩子不等待
- wso2 - WSO2 Identity Server 5.9.0 在集群设置中因以下数据库错误而崩溃?