繁体   English   中英

MacOS X 10.11.3 中的 F# 目录和路径

[英]F# Directory and paths in MacOS X 10.11.3

嗨,我是 MacOS X (10.11.3) 的新手,到目前为止在 Win8.1 上的 VS2015 中使用过 F#

我有一些问题:

1- 在 F# Interactive 中,如果我想说,有目录 ~/Documents 的文件列表

Directory.GetFiles(@"~/Documents")不起作用。 什么是正确的语法?

如果我想做一个#r xxx.dll ,我该如何正确指定路径

2- 源文件(.fs 或 .fsx)中的相同问题

谢谢

编辑例如我在 F# 交互式中得到以下内容

让 CD = "/文件";;

val CD : string = "/Documents"

Directory.GetFiles(CD);;

System.IO.DirectoryNotFoundException: 找不到目录“/Documents”。

在 System.IO.Directory.ValidateDirectoryListing (System.String path, System.String searchPattern, System.Boolean& stop) <0x1a22580 + 0x001f8> in 0 at System.IO.Directory.GetFileSystemEntries (System.String path, System.String searchPattern, FileAttributes mask, FileAttributes attrs) <0x1a22800 + 0x00061> in 0 at System.IO.Directory.GetFiles (System.String path, System.String searchPattern) <0x1a21bf0 + 0x00034> in 0 at System.IO.Directory.GetFiles (System. String path) <0x1a21bb0 + 0x00027> in 0 at FSI_0031.main@ () <0x73a07f0 + 0x00013> in 0 at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection,objectMonoMethod,object) [],System.Exception&) at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfoculture) <0x1a7c850 + 0x000a1>在 0 由于错误而停止

我假设您可能正在使用 Mono/Xamarin? 我没有使用 MacOS 的经验,但 .NET 应该可用。 您可以使用以下命令访问您的主目录: System.Environment.GetEnvironmentVariable("USERPROFILE")还有其他变量访问特殊文件夹,但我不确定 Windows 是如何特定的。 对于第二个问题,您可以使用#I @"path/to/dll"指定 dll 所在的文件夹,然后使用#r @"file.dll"添加 dll 名称。 这适用于 fs 和 fsx 文件。 你可能想把它放在#if INTERACTIVE #endif块之间。 对于已编译的内容,您可以直接在 IDE 中添加对 DLL 的引用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM