我是第一次用 C# 编写代码并遇到了这个问题。
我使用函数 File.WriteAllBytes(OutputFileName, dest);
它正在磁盘上创建一个文件,当我的应用程序尝试使用 file.Open
打开同一文件时给我一个异常(exception)访问路径被拒绝。请帮我摆脱这个。我在 Windows 7 上,不是以管理员身份运行。
谢谢。
最佳答案
文件已关闭。由于其他原因被拒绝。检查路径,或者您可以使用 FileMode File.Open(path, FileMode.Open)
打开它。否则请检查您的权限。
Given a byte array and a file path, this method opens the specified file, writes the contents of the byte array to the file, and then closes the file.
关于c# - 创建文件后如何关闭文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21426354/