- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
根据有关Path.Combine
方法的官方文档:https://msdn.microsoft.com/en-us/library/fyy7a5kt(v=vs.110).aspx
Remarks
If path1 is not a drive reference (that is, "C:" or "D:") and does not end with a valid separator character as defined in DirectorySeparatorChar, AltDirectorySeparatorChar, or VolumeSeparatorChar, DirectorySeparatorChar is appended to path1 before concatenation.
这意味着它不会在盘符后面加上\
,所以这段代码:
var path1 = @"c:";
var path2 = @"file.txt";
Path.Combine(path1, path2);
将生成 C:file.txt
,它不会强制指向放置在 c:
中的文件 file.txt
。
这背后的原因是什么?
最佳答案
Path.Combine
以这种方式工作,因为 c:file.txt
实际上是一个有效路径。
根据 Microsoft documentation on NTFS paths :
If a file name begins with only a disk designator but not the backslash after the colon, it is interpreted as a relative path to the current directory on the drive with the specified letter. Note that the current directory may or may not be the root directory depending on what it was set to during the most recent "change directory" operation on that disk.
简而言之,c:file.txt
会搜索C盘当前目录下的文件,而c:\file.txt
会搜索驱动器根文件夹中的文件(忽略当前目录)。
由于 Path.Combine
无法知道您期望的行为是什么,因此它无法自动添加反斜杠。
关于c# - 具有驱动器号的 Path.Combine() 行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19909008/
我想使用 Haskell 的 parsec 库来实现这个语法规则: ((a | b | c)* (a | b))? 这是一个接受可选(即可能为空)字符串的解析器规则。如果它接受的字符串不为空,则可以通
Python 的 itertools.combinations() 创建的结果是数字的组合。例如: a = [7, 5, 5, 4] b = list(itertools.combinations(a
I found a good script for the permutation of lists, combining and not combining list position on
我正在使用 Beam 管道计算流式数据的电话号码频率。我使用的滑动窗口每 5 分钟重复一次,总周期为 15 分钟,因此正如预期的那样,对于某些输入,当输入落在多个窗口中时,我会得到多个输出。 计算出现
这个问题已经有答案了: Pandas Merging 101 (8 个回答) 已关闭 3 年前。 我有两个数据帧,我想对其执行外连接。两个数据框共享一个公共(public)索引名称以及多个也共享相同名
我在谷歌上搜索了很多天这个问题,但一无所获。我需要做一个 SELECT,DUPLICATE 和 DUPLICATE 和 DUPLICATE 取决于用户。之后,我需要将每个选项的值组合到我选择的一个选择
这个问题在这里已经有了答案: Java 8 Streams: multiple filters vs. complex condition (4 个答案) 关闭 4 年前。 需要过滤所有适合其领域某
运行 cv2.getRectSubPix(img, (5,5), (0,0)) 抛出错误: OpenCV Error: Unsupported format or combination of for
没有重复的组合看起来像这样,当可供选择的元素数 (n) 为 5 且选择的元素数 (r) 为 3 时: 0 1 2 0 1 3 0 1 4 0 2 3 0 2 4 0 3 4 1 2 3 1 2 4 1
我在学校的数学一直不太好,我意识到我实际上需要与 pow(base, exponent) 函数相反的函数,该函数对某个数字进行乘方运算,例如 2 ^ 4 = 16 搜索答案我发现对数 log() 应该
我确信这很简单,但我很难找到一种方法来做到这一点。基本上,如果我有一个包含 P 列和 V^P 行的数组,我如何填写所有组合,即基本上所有可能的数字以 P 数字的 V 为基数。例如,对于 P=3 和 V
我想知道一种可能的算法来计算所有可能的组合,没有重复,从 length=1 开始,直到 length=N 的 N 个元素。 例子: 元素:1、2、3。 输出: 1 2 3 12 13 23 123 最
使用三种不同颜色的颜料可以用多少种不同的方式来绘制立方体? 最佳答案 如果您以唯一可能的有趣方式解释它,那么这是一个比 3^6 更难的问题:有多少种不同的(即对称的)方法来为立方体着色。这是一篇论文:
我正在尝试解决优化问题,但首先我必须找到 n 个元素的所有可能组合的数量,但要考虑一些冲突。一个可能的例子是: 元素:{1,2,3,4}冲突:{1,2},{3,4} 术语“冲突”是指属于同一冲突集合的
Cleave 是一个非常有用的组合器,可以最大限度地减少代码重复。假设我要分类 Abundant, Perfect, Deficient numbers : USING: arrays assocs
有没有办法让 @Published 变量只在新值与旧值不同时才发布其值? 现在如果我们有 @Published var test: Bool = false 我们做到了 test = false te
有一个数组 [1, 2, ..., m] ,并且有一个整数 n . 如 m=2和 n=3 ,我想获得 [1, 1, 1] [1, 1, 2] [1, 2, 1] [1, 2, 2] [2, 1, 1]
我在我的应用程序中使用了一个用于日志记录页面的表单,并且在页脚上有一个绑定(bind)来显示任何错误,如下所示: 内容 View .Swift : Form { Section(footer: Tex
HTML first second third SCSS $statistics: ("first", "second", "third"); :root { --first: r
我有一个 HTTP 请求发布者,当返回 401 错误时,我想停止执行并显示我的登录屏幕。 这是我的代码的一部分: cancellable = fetcher.hello(helloRequest: H
我是一名优秀的程序员,十分优秀!