Search code examples
c#visual-studioclass-library

Visual Studio 2017 Class Library Project: Could not load file or assembly System.IO.FileSystem


I am developing a .NETStandard Class Library in c#, and then using a .NET Framework unit test project to test it. The problem line of code is;

    using System.IO;

    /*
     * Returns true if @strFile points to a file on the system,
     * Otherwise Returns False
     * 
     */
    private Boolean checkFileExists(string strFile)
    {
        return File.Exists(strFile);
    }

It is throwing the exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.IO.FileSystem, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

How do I make sure the class library project can find this library?

Thanks


Solution

  • Click on links below for images of the steps

    In Visual Studio, Select Tools/NuGet Package Manager/Package Manager Console

    enter this at nuget Command Line

    This will install the latest System.IO.FileSystem Package from Microsoft.