1
我试图创建一个脚本,它将使用C#在Visual Studio上打开一个CSV文件,但是当我引用File类时,错误会弹出:命名空间'System.IO'中不存在类型或命名空间名称'File'
The type or namespace name 'File' does not exist in the namespace 'System.IO'
我确信,我using System
以及using System.IO
去增加对System.dll
和System.IO.dll
引用,但是当我尝试并加入他们,我得到的错误:
A reference to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.dll' could not be added. This component is already automatically referenced by the build system.
System.IO.dll出现同样的错误。
我使用.NETFramework V4.6和Visual Studio 2015年
不能确定错误的实际原因,但不需要为System.dll和System.IO.dll添加引用,它们默认包含在新项目中。使用语句应该已经足够了 –
使用正确的项目模板来使用这个类。经典桌面,而不是商店或通用项目。 –
启动一个新的Windows桌面项目(WinForms/WPF/Console/Class Library ....)并查看错误是否持续。如果没有,请将您当前的项目移植到新项目中。 –