- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在使用以下 P/Invoke 签名来获取常规 Windows 文件的短文件名:
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern int GetShortPathName([MarshalAs(UnmanagedType.LPTStr)] string path,
[MarshalAs(UnmanagedType.LPTStr)] StringBuilder shortPath,
int shortPathLength);
目前 - 它没有任何问题,但我注意到一些很奇怪的事情:
我知道 Windows 使用以下短文件名 约定:
Cut the name to 6 characters (without extension)
Append the tilde (~
)
Append an unsigned integer number which indicates the match index (starting with 1)
Append the original file extension
因此,文件名 C:\abcdefghijklmn.txt
应该可以在短名称 C:\abcdefg~1.txt
下访问。 (工作正常。)
现在是奇怪的部分:我最近在我的音乐目录中进行了一次小型搜索以查找特定的音频文件。这是结果:
.\Rammstein & Tatu - Moscow.mp3
.\Rammstein - Asche zu Asche.mp3
.\Rammstein - Der Meister.mp3
.\Rammstein - Du Hast.mp3
.\Rammstein - Eifersucht.mp3
.\Rammstein - Feuer Frei.mp3
.\Rammstein - Führe Mich.mp3
.\Rammstein - Haifisch.mp3
...
和相同的简写搜索:
.\RA8E17~1.MP3
.\RA23A6~1.MP3
.\RAMMST~1.MP3
.\RA0CAE~1.MP3
.\RAMMST~2.MP3
.\RAMMST~3.MP3
.\RAMMST~4.MP3
.\RA6BAA~1.MP3
...
我的问题是:为什么 Windows 在波浪号之前生成这样的“随机”前缀(如 RA23A6
或 RA0CAE
)?
最佳答案
Microsoft 没有对此进行记录,但维基百科有:
Although there is no compulsory algorithm for creating the 8.3 name from an LFN, Windows uses the following convention:
1.If the LFN is 8.3 uppercase, no LFN will be stored on disk at all.
- Example:
TEXTFILE.TXT
2.If the LFN is 8.3 mixed case, the LFN will store the mixed-case name, while the 8.3 name will be an uppercased version of it.
- Example:
TextFile.Txt
becomesTEXTFILE.TXT
.3.If the filename contains characters not allowed in an 8.3 name (including space which was disallowed by convention though not by the APIs) or either part is too long, the name is stripped of invalid characters such as spaces and extra periods. Other characters such as
+
are changed to the underscore_
, and uppercased. The stripped name is then truncated to the first 6 letters of its basename, followed by a tilde, followed by a single digit, followed by a period.
, followed by the first 3 characters of the extension.
- Example:
TextFile1.Mine.txt
becomesTEXTFI~1.TXT
(orTEXTFI~2.TXT
, shouldTEXTFI~1.TXT
already exist).ver +1.2.text
becomesVER_12~1.TEX
.4.Beginning with Windows 2000, if at least 4 files or folders already exist with the same initial 6 characters in their short names, the stripped LFN is instead truncated to the first 2 letters of the basename (or 1 if the basename has only 1 letter), followed by 4 hexadecimal digits derived from an undocumented hash of the filename, followed by a tilde, followed by a single digit, followed by a period
.
, followed by the first 3 characters of the extension.
- Example:
TextFile.Mine.txt
becomesTE021F~1.TXT
.
正如 Joey 所提到的,文件名的未记录哈希值 是 reverse engineered .
关于windows - Windows 中如何生成短文件名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31526206/
任何帮助深表感谢。我正在尝试创建一个 SSIS 包来遍历文件夹中的文件并获取路径+文件名,最后执行存储的过程,参数为路径+文件名。我不确定如何获取路径+文件名并将其作为参数插入到存储过程中。我附上了截
我想编写一个小脚本来搜索确切的文件名,而不是文件名中的字符串。 例如,如果我使用资源管理器搜索“主机”,默认情况下我会得到多个结果。对于脚本,我只需要我指定的名称。我假设这可能吗? 我才真正开始编写脚
str(文件.key) = '1011/101011/文件名' newFileName = str(file.key) 但是,当我运行代码时,我得到: UnicodeEncodeError: 'asc
下面这段子程基本上可以算是比较不错的通用匹配了。(PS:我突然发现CODE_LITE把我的UBB转义了!!!晕,我只好自己转义了。。。) Dim objRegExp,Matc
PHP 无法处理带有 Unicode 字符的文件:当我在浏览器上访问 testSite/главная.php 时,它会抛出此错误。 Warning: Unknown: failed to open
我正在尝试包含 Dim在 Vlookup 中。 Dim filename As String filename = Format(DateAdd("d", -6, Now()), "mm-dd-yy"
在我的日常构建项目中,我们将其库存储到其版本名称目录中。 . 对于最新的,我们正在创建符号链接(symbolic link)作为“最新”。 前任。- ls -ltr drw-r--r-- 1 4096
重新安装了 Windows 10(版本 10.0.14393)。重新安装了以下内容: java java version "1.8.0_121" Java(TM) SE Runtime Environ
我想使用 Jekyll 和 GitHub Pages 构建文档站点。问题是 Jekyll 只接受 _posts 下的文件名具有精确的图案,如 YYYY-MM-DD-your-title-is-here
我不知道我发生了什么事。我想访问一个包含多个文件的目录,假设: folder\\1.txt 2.txt 3.txt.... 现在我想根据它们的出现情况来阅读它们,我的意思是首先是最低的,只是我想按升
如何将/放入文件名(即/不分隔路径的组成部分)? 最佳答案 你不知道。 UNIX 文件名中不允许使用斜线。 关于unix - 你如何获得 a/into 文件名?,我们在Stack Overflow上找
我需要复制一个大文件夹,并重命名其中的所有文件和文件夹(如果它们包含特定字符串)。基本上我想复制所有内容并将 10 的任何实例更改为 11。 例如,如果我有一个结构如下的文件夹: mainfolder
我有一个简单的 python (2.7) 脚本,应该执行一些 svn 命令: def getStatusOutput(cmd): print cmd p = subprocess.Po
我正在尝试读取以字符串形式存储在数据文件中的文件名。那里没问题。如果我将它传递给 genfromtxt,我会收到错误“IOError:Z:\Python\Rb input.txt not found”
简单的问题。 当我尝试打开名为 text.txt 的文件时,它可以正常工作。 但是,如果我将文件重命名为 text.cir.txt,则会出现错误。 我可以做什么来修复它? FILE *fd; char
我是 c# 的业余爱好者,我一直无法找到这个问题的答案。也许我不知道要使用的正确术语。 当一个视频文件被拖到我的 exe 应用程序上时,我希望应用程序知道它是用一个文件启动的,并且能够知道该文件的路径
我知道我必须使用 Substring 来删除,但我不知道该怎么做。我需要像这样删除字符串的结尾 来自 "C:\\Users\\myname\\Pictures\\shoeImage.jpg" 到 "C
运行 eclipse 时我收到此错误。但是当我运行我的项目时,它是在内部浏览器中执行的。但它不会在默认的系统浏览器中执行。对此任何一个答案。先谢谢您的回答 最佳答案 您可以从 eclipse 更改浏览
我想要求用户选择一个要从外部存储打开的文件并接收它的路径。最好我想避免过多的编码并使用一些标准方法(众所周知,系统提供的 Intent 或类似方法)。所说的文件是SpatiaLite db文件(*.s
我有一个文件名数据库,我正在尝试使用 PG 的全文搜索工具在其中进行搜索。我在文件名表上运行搜索查询,问题是排名函数没有按照我希望的那样对结果进行排名。为了便于讨论,我们假设架构如下所示: creat
我是一名优秀的程序员,十分优秀!