Reputation: 133
I'm trying to read text file using System.IO.File.ReadAllLines
-method but an error pops up saying
The type or namespace 'File' does not exist in the namespace 'System.IO' (are you missing an assembly reference?
I'm working with .Net Framework 4.5 and VS2012.
Upvotes: 0
Views: 15277
Reputation: 416039
That assembly is not available to you when building Windows Store (UWP) apps.
Instead, there is a different mechanism you must use. This mechanism encourages a more modern view of file I/O that embraces asynchronous (non-blocking) access the use of buffers and libraries, as well as support for more kinds of devices that may not use traditional file paths.
Upvotes: 1
Reputation: 1025
First go to Solution Explorer and Expand References and check whether System assembly is there in the list.
If you don't have it there, right click references and click add Reference and from the .NET tab, add System assembly
Now you should have System in the References list.
Now you can import the namespace System.IO as
using System.IO;
Note that File is a class in namespace System.IO
So just use the File class in the code as follows.
File f = new File();//or whatever
I know the last line is sufficient but put down the whole thing for the completion. ;)
Upvotes: 0