Jon*_*eet 19
你不能,基本上 - 你必须尝试打开文件写,如果你得到一个例外,你不能写它:(
即使您可以先进行单独检查,结果也会在您开始编写之前过时 - 您仍然可以在以后查看异常.
如果框架提供了一种TryOpen方法,那将是很好的,诚然......
close在代码上使用后,您必须访问您的文件:
FileStream file = new FileStream(fileName, FileMode.Open, FileAccess.Read); //file is opened
//you use the file here
file.Close(); //then you must to close the file
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
44055 次 |
| 最近记录: |