首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >File.ReadAllText和File.WriteAllText之后

File.ReadAllText和File.WriteAllText之后
EN

Stack Overflow用户
提问于 2014-04-08 17:08:36
回答 1查看 761关注 0票数 1

我的问题是,当我运行这段代码时,它的"File.WriteAllText“行告诉我procedure.pas正在被另一个程序使用。

代码语言:javascript
复制
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);
EN

回答 1

Stack Overflow用户

发布于 2014-04-08 17:14:23

您正在写入的文件可能是使用共享锁打开的,该共享锁允许其他进程读取数据,但不允许写入。因此,当您打开要写入的文件时,它会失败并出现异常,尽管该文件一直由另一个进程打开。

有关这方面的详细信息,请参阅FileShare枚举。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22932484

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档