我堅持我的程序在C#中。所以用戶必須按一個按鈕來創建一個隨機字符串(工作正常),然後他可以選擇點擊另一個按鈕。這個打開一個filedialog並讓他選擇一個他想要重命名爲隨機字符串的dll文件。我無法得到它的工作。它說我的dll已經在另一個進程中運行(不是)。任何幫助非常感謝:)c#/重命名DLL使用OpenFileDialog
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;
}
'至極是not'你覺得NET和操作系統在騙你? Nothinkg的好處可以讓用戶重新命名DLL。請閱讀[問]並參加[導遊] – Plutonix
是的。 _You_通過創建一個StreamReader來使用它。無論如何,StreamReader有什麼意義? –
重命名.dlls基本上將它們孤立起來。加** kernel32.dll **會得到一個脾氣暴躁的 – MickyD