📜  ASP ShortName 属性

📅  最后修改于: 2022-05-13 01:56:36.002000             🧑  作者: Mango

ASP ShortName 属性

ASP ShortName 属性用于获取系统上指定文件或文件夹的短名称。

句法:

  • 对于文件对象:

    FileObject.ShortName
  • 对于文件夹对象:

    FolderObject.ShortName

    下面的示例说明了ASP ShortName 属性

    示例 1:下面的代码说明了 ASP File.ShortName 属性。

    ASP
    <%
    dim fs,f
    set fs=Server.CreateObject("Scripting.FileSystemObject")
        
    'Getting the file
    set f=fs.GetFile("d:\alargefilename.txt")
      
    'Getting the full name of the file
    Response.Write("Full Name: " & f.Name)
      
    'Getting the short name of the file
    Response.Write("
    Short Name: " & f.ShortName)    set f=nothing set fs=nothing %>


    ASP
    <%
    dim fs,fol
    set fs=Server.CreateObject("Scripting.FileSystemObject")
        
    'Getting the folder
    set fol=fs.GetFolder("d:\geeksforgeeksfolder")
      
    'Getting the full name of the folder
    Response.Write("Full Name: " & fol.Name)
      
    'Getting the short name of the folder
    Response.Write("
    Short Name: " & fol.ShortName)    set fol=nothing set fs=nothing %>


    输出:

    Full Name: alargefilename.txt
    Short Name: ALARGE~1.TXT

    示例 2:下面的代码说明了 ASP File.ShortName 属性。

    ASP

    <%
    dim fs,fol
    set fs=Server.CreateObject("Scripting.FileSystemObject")
        
    'Getting the folder
    set fol=fs.GetFolder("d:\geeksforgeeksfolder")
      
    'Getting the full name of the folder
    Response.Write("Full Name: " & fol.Name)
      
    'Getting the short name of the folder
    Response.Write("
    Short Name: " & fol.ShortName)    set fol=nothing set fs=nothing %>

    输出:

    Full Name: geeksforgeeksfolder
    Short Name: GEEKSF~1