倒,居然可以,多谢楼上:)
不过我现在是写死成“C:\PROGRA~1”可以成功备份到“C:\Program Files”,但是备份路径是用户可以随便选择的,我如何自动将有空格的转成~1,~2这种形式呢,PS,我用的是c#

解决方案 »

  1.   

    API函数GetShortPathName可以获取8.3格式的短文件名Declare Function GetShortPathName Lib "kernel32" Alias _   "GetShortPathNameA" (ByVal lpszLongPath As String, _   ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
      

  2.   

    C#调用:[DllImport("kernel32.dll", CharSet = CharSet.Auto)] 
    public static extern int GetShortPathName

      [MarshalAs(UnmanagedType.LPTStr)] 
      string path, 
      [MarshalAs(UnmanagedType.LPTStr)] 
      StringBuilder shortPath, 
      int shortPathLength
    ); 
    //使用此函数很简单 StringBuilder shortPath = new StringBuilder(80); 
    int result = GetShortPathName( 
    @"d: est.jpg", shortPath, shortPath.Capacity); 
    string s = shortPath.ToString(); 
      

  3.   

    俺只知道 ,在很多地方使用 双引号可以 作为路径传入 
    如:
    CD ‘Program files’ --错误
    应该
    cd "Program files" --就可以--个人意见