I am trying to instantiate a class ZipArchivein System.IO.Compressionin an F # project:
open System.IO
open System.IO.Compression
open System.IO.Compression.FileSystem
let directoryPath = @"C:\Users\max\Downloads"
let dirInfo = new DirectoryInfo(directoryPath)
let zippedFiles = dirInfo.GetFiles()
|> Array.filter (fun x -> x.Extension.Equals(".zip"))
let fileStream = new FileStream(((Array.head zippedFiles).FullName), System.IO.FileMode.Open)
let archive = new System.IO.Compression.ZipArchive(fileStream)
I can create the same in C # in the correct namespace:
var unzipper = new System.IO.Compression.ZipArchive(null);
(This gives a bunch of errors because I am missing zero, but at least I can try to access it).
I do have a link System.IO.Compression.FileSystemin my F # project (as well as the parent namespace System.IO.Compression). However, when I load the namespace, .FileSystemI get the error "The namespace" FileSystem "is not defined."
EDIT
Added a full script file that I am trying to execute that reproduces the problem.
As shown in the instructions open, my project references both of these libraries:
System.IO.Compression
System.IO.Compression.FileSystem
I run:
- F # 4.4
- .NET 4.6.1
- Visual Studio 2015
- Windows 10 64
2: !
F # script, .fsx, , DLL :
#if INTERACTIVE
#r "System.IO.Compression.dll"
#r "System.IO.Compression.FileSystem.dll"
#endif