【发布时间】:2017-11-28 19:20:03
【问题描述】:
我被我的 C# 程序卡住了。所以用户必须按下一个按钮来创建一个随机字符串(工作正常),然后他可以选择点击另一个按钮。这个打开一个文件对话框,让他选择一个他想重命名为随机字符串的 dll 文件。我无法让它工作。它说我的 dll 已经在另一个进程中运行(不是)。非常感谢任何帮助:)
private void btnEncrypt_Click_1(object sender, EventArgs e)
{
// sets a random string to txtEncrypt.text
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog MyOpenFileDialog = new OpenFileDialog();
//filedialog
MyOpenFileDialog.Filter = "dll files (*.dll) |*.dll";//filter
MyOpenFileDialog.Title = "Chose the dll file";
MyOpenFileDialog.InitialDirectory = "C:\\Users\\Gebruiker\\Desktop";
MyOpenFileDialog.FilterIndex = 1;
MyOpenFileDialog.RestoreDirectory = true;
//if ok
if (MyOpenFileDialog.ShowDialog() == DialogResult.OK)
{
strPath = MyOpenFileDialog.FileName;
StreamReader reader = new StreamReader(strPath);
System.IO.File.Move(strPath, "C:\\Users\\Gebruiker\\Desktop\\" + txtEncrypt.Text + ".dll");
}
else //cancel
{
strPath = null;
}
【问题讨论】:
-
wich is not你认为 NET 和操作系统在骗你吗?无论如何,让用户重命名 DLL 是没有什么好处的。请阅读How to Ask 并采取tour -
是的。 您通过创建
StreamReader来使用它。StreamReader到底有什么意义? -
重命名 .dll 基本上会孤立它们。再加上 kernel32.dll 会有点脾气暴躁
标签: c# dll rename openfiledialog