【发布时间】:2014-04-08 17:14:23
【问题描述】:
我的问题是,当我运行此代码时,它告诉我“File.WriteAllText”行 procedure.pas 正在被另一个程序使用。
script = File.ReadAllText(Application.StartupPath + "\\Procedure.pas");
decryptedstring = Crypter.Decrypt(script, sSecretKey);
decryptedstring = decryptedstring.Replace("_" + Firma + "_", "_" + txtFirma.Text + "_");
decryptedstring = decryptedstring.Replace("_" + DonemNo + "_", "_" + txtDonemNo.Text + "_");
decryptedstring = decryptedstring.Replace("FIRMNR=" + Firma + " ", "FIRMNR=" + txtFirma.Text + " ");
encryptedstring = Crypter.Encrypt(decryptedstring, sSecretKey);
File.WriteAllText(Application.StartupPath + "\\Procedure.pas", encryptedstring);
【问题讨论】:
-
你对 Application,StartupPath 有写权限吗?
-
在 WriteAllText 之前放置一个断点并使用 Windows 资源监视器来检查谁在使用这个文件 - 只是为了好奇......
-
我猜你也想写的文件被另一个程序使用了?! ://