当路径没有目录分隔符时会发生什么?

时间:2010-09-29 09:24:01

标签: windows relative-path dos

C:WProgram Files

有谁知道这样的位置?如何在程序中处理,与\相同?

1 个答案:

答案 0 :(得分:2)

相对于该驱动器号的当前目录,解析具有驱动器号然后相对路径的路径。

Windows和MS-DOS系统分别跟踪每个驱动器号的当前目录。

例如:

G:\>dir c:
 Volume in drive C is System
 Volume Serial Number is A09A-AD9C

 Directory of C:\

06/12/2008  02:44 PM                 0 AUTOEXEC.BAT
06/12/2008  02:44 PM                 0 CONFIG.SYS
08/25/2008  02:22 PM    <DIR>          Documents and Settings
12/09/2009  12:45 PM    <DIR>          Program Files
[snip]

G:\>cd "c:\Program Files"

G:\>dir c:
 Volume in drive C is System
 Volume Serial Number is A09A-AD9C

 Directory of C:\Program Files

12/09/2009  12:45 PM    <DIR>          .
12/09/2009  12:45 PM    <DIR>          ..
05/14/2010  11:38 AM    <DIR>          7-Zip
12/13/2010  01:49 AM    <DIR>          Adobe
[snip]

G:\>dir c:Adobe
 Volume in drive C is System
 Volume Serial Number is A09A-AD9C

 Directory of C:\Program Files\Adobe

12/13/2010  01:49 AM    <DIR>          .
12/13/2010  01:49 AM    <DIR>          ..
01/25/2010  01:45 AM    <DIR>          Reader 8.0
12/13/2010  01:49 AM    <DIR>          Reader 9.0

路径c:AdobeC:\Program Files\Adobe相同,因为这是C驱动器的当前目录,即使当前驱动器实际上是G驱动器。