vb.net中OpenMode.input和OpenMode.output的说明 [英] Explanation of OpenMode.input and OpenMode.output in vb.net

查看:532
本文介绍了vb.net中OpenMode.input和OpenMode.output的说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道为什么使用openmode.input来显示文件;相比之下,openmode.output可以写文件吗?

I''m wondering why openmode.input is used to display file; in contrast, openmode.output for writing a file?

推荐答案

首先,我建议仅使用标准.NET库(而不是Microsoft.*)中的API. ).至少,不要使用任何特定于VB.NET的东西:您永远不需要它.我想这样的API的目的是简化从VB的迁移.如果在新开发中甚至在VB.NET中使用它,则只会创建潜在的不兼容性源. .NET库的很大一部分是在ECMA下标准化的,但是VB.NET库有点(而且很可能永远不会).

如果是文件,请使用System.IO.File.Open http://msdn.microsoft.com/en-us /library/b9skfh7s.aspx [ ^ ],System.IO.StreamReader http://msdn.microsoft.com/en -us/library/system.io.streamreader.aspx [ http://msdn.microsoft.com/en-us/library/system.io.binaryreader.aspx [ http://msdn.microsoft.com/en-us/library/system.io.binarywriter.aspx [
First of all, I would advice to use only the API from standard .NET libraries (not Microsoft.*). At least, don''t use anything VB.NET-specific: you never need it. I thing the purpose of such API was simplification of migration from VB. If you use it in new development, even in VB.NET, you only create sources of potential incompatibilities. Big part of .NET libraries is standardized under ECMA, but bit VB.NET library (and most likely will never be).

In the case of files, use System.IO.File.Open, http://msdn.microsoft.com/en-us/library/b9skfh7s.aspx[^], System.IO.StreamReader, http://msdn.microsoft.com/en-us/library/system.io.streamreader.aspx[^], System.IO.StreamWriter, System.IO.BinaryReader, http://msdn.microsoft.com/en-us/library/system.io.binaryreader.aspx[^], System.IO.BinaryWriter, http://msdn.microsoft.com/en-us/library/system.io.binarywriter.aspx[^], etc.

As to the question, please see my comment to it. My hint was: it does not really need much explanation. It is natural that reading of the file should be protected from accidental writing and visa versa. Read/write mode should be declared explicitly; and it is used not often.

—SA


这篇关于vb.net中OpenMode.input和OpenMode.output的说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆