Directory.CreateDirectory does not exist in .NET Core

I am trying to use Directory.CreateDirectory in .NET Core. But it does not seem to exist. Is there any other way to create a directory in .NET Core? Here is a part of my project. Json:

  "dependencies": { "EntityFramework.SqlServer": "7.0.0-beta4", "EntityFramework.Commands": "7.0.0-beta4", "Microsoft.AspNet.Mvc": "6.0.0-beta4", "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta4", "Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta4", "Microsoft.AspNet.Authentication.Facebook": "1.0.0-beta4", "Microsoft.AspNet.Authentication.Google": "1.0.0-beta4", "Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-beta4", "Microsoft.AspNet.Authentication.Twitter": "1.0.0-beta4", "Microsoft.AspNet.Diagnostics": "1.0.0-beta4", "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta4", "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta4", "Microsoft.AspNet.Server.IIS": "1.0.0-beta4", "Microsoft.AspNet.Server.WebListener": "1.0.0-beta4", "Microsoft.AspNet.StaticFiles": "1.0.0-beta4", "Microsoft.AspNet.Tooling.Razor": "1.0.0-beta4", "Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta4", "Microsoft.Framework.ConfigurationModel.UserSecrets": "1.0.0-beta4", "Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-beta4", "Microsoft.Framework.Logging": "1.0.0-beta4", "Microsoft.Framework.Logging.Console": "1.0.0-beta4", "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta4", "System.IO.FileSystem.Primitives" : "4.0.0-beta-22816", "System.IO.FileSystem": "4.0.0-beta-22816", "Mandrill.Client": "1.0.0-*", "Microsoft.AspNet.Session": "1.0.0-beta4" }, "commands": { "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000", "gen": "Microsoft.Framework.CodeGeneration", "ef": "EntityFramework.Commands" }, "frameworks": { "dnx451": { }, "dnxcore50": { } }, "exclude": [ "wwwroot", "node_modules", "bower_components" ], "publishExclude": [ "node_modules", "bower_components", "**.xproj", "**.user", "**.vspscc" ], "scripts": { "postrestore": [ "npm install", "bower install" ], "prepare": [ "gulp copy" ] } } 

I have dll-s successfully restored in .NET Core, as in the attached figure: NET core reference


Update: The problem does not exist. When I run this code on .NET Core, it works. Only an incorrect mouse description is incorrect, which indicates inaccessibility for .NET Core. I recommend deleting this question.

+5
source share
1 answer

Fix Dependencies / Framework Assembly

Since System.IO.FileSystem is a dependency on .NET Core (the full .NET framework already has these types in System.IO and mscorlib ), you need to move it from dependencies to dnxcore50.dependencies .

Example:

 "frameworks": { "dnx451": { "frameworkAssemblies": { "System.Collections": "", "System.IO": "", "System.Runtime": "", "System.Xml": "", "System.Xml.Linq": "", "System.Threading.Tasks": "", "System.Text.Encoding": "" } }, "dnxcore50": { "dependencies": { "System.IO": "4.0.10-beta-*", "System.Console": "4.0.0-beta-*", "System.Linq": "4.0.0-beta-*", "System.Reflection": "4.0.10-beta-*", "System.Runtime": "4.0.20-beta-*", "System.Threading.Tasks": "4.0.10-beta-*", "System.ComponentModel": "4.0.0-beta-*" } } } 

Firstly, the dependencies node refers to the agnostic dependencies of the "framework", that is, to the dependencies that work in all the environments that you specified in the frameworks node.

dnx451.frameworkAssemblies (full .NET Framework 4.5.1) node is for GAC assemblies that ship with the full .NET platform. They are not loaded via NuGet, but rather simply referenced in your project.

Finally, dnxcore50.dependencies node is for .NET Core dependencies. This is the new set of NuGet packages that together form the .NET Core. They download and link to NuGet.

Restore packages

You need to make sure that the package itself has been restored. Sometimes declaring a dependency in project.json is not enough.

If you edit the project.json file in Visual Studio, it should automatically restore packages when the file is saved. Otherwise, you can try running dnu restore in the project.json directory.

Alternatively, you can try changing the version to 4.0.0-beta-* .

+5
source

All Articles