0

Getting the following error:

The name 'File' does not exist in the current context[dnxcore50]


Tried to build it in-case it was to do with VSCode alone. It threw me same error. I have installed the dependency using the following:

dnu install System.IO

Gave me the following message

c:\Users\user1\Dropbox\dev\csharp\vscode\ads\WeightedGraphs>dnu install System.IO GET https://www.nuget.org/api/v2/FindPackagesById()?Id='System.IO'. OK https://www.nuget.org/api/v2/FindPackagesById()?Id='System.IO' 679ms System.IO.4.0.10-beta-22816 was added to project.json. Restoring packages for c:\Users\user1\Dropbox\dev\csharp\vscode\ads\WeightedGraphs\project.json Writing lock file c:\Users\user1\Dropbox\dev\csharp\vscode\ads\WeightedGraphs\project.lock.json Restore complete, 302ms elapsed

project.json

{
    "version": "1.0.0-*",
    "dependencies": {
        "System.IO": "4.0.10-beta-22816"
    },
    "commands": {
        "run": "run"
    },
    "frameworks": {
        "dnx451": {},
        "dnxcore50": {
            "dependencies": {
                "System.Collections": "4.0.10-beta-22816",
                "System.Linq": "4.0.0-beta-22816",
                "System.Console": "4.0.0-beta-22816"
            }
        }
    }
}


In.cs

using System.IO;
public class In{
    public In(string s){
        var filename = s;
        var path = "";
        if(File.Exists(path)){  
            //Code TO Be Added
        }
    }
}

1 Answer 1

1

You also need to add "System.IO.FileSystem" to your dependencies.

Sign up to request clarification or add additional context in comments.

3 Comments

thank you, that fixed the problem. How ever curiour, how should i know
looking into docs(msdn.microsoft.com/en-us/library/…), does not give me that info, neither do I add that dependency when i use Visual Studio.
Yes, this is one of the oddities of .NET Core. As .NET Core is still a work in progress and much of its documentation has not been written yet. (dotnet.readthedocs.org/en/latest)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.