FileName

Descrizione

Restituisce il nome del percorso del file allegato.

Si tratta di una proprietà di sola lettura; è possibile visualizzarla, ma non impostarla.

Prima che fosse eseguito il commit dell'allegato al database, questa proprietà conteneva il nome del percorso di origine del file. Tuttavia, dopo aver eseguito il commit dell'allegato, il file è presente nel database anziché nel file system, in modo da rimuovere le informazioni sul percorso. Ad esempio, se si aggiunge il file C:\projectsmyfilesexample.txt, esso avrà il nome completo fino a quando non verrà eseguito il commit del record; successivamente, il nome verrà abbreviato in example.txt.

In Rational ClearQuest allegare due file con lo stesso nome e differenti informazioni sul percorso allo stesso database è un'operazione valida. Rational ClearQuest non si basa sul solo filename durante il posizionamento interno del file. Inoltre, è presente una limitazione di 50 caratteri per la lunghezza del nome file.

Sintassi

VBScript

attachment.FileName 

Perl

$attachment->GetFileName(); 
Identificativo
Descrizione
attachment
Un oggetto Attachment che rappresenta l'allegato di un file in un record.
Valore di ritorno
Una stringa contenente il nome del file allegato.

Esempio

VBScript

' This example assumes there is at least 1 attachment field
' and 1 attachment associated with the record.
set currentSession = GetSession
set attachFields = AttachmentFields
set attachField1 = attachFields.Item(0)
set theAttachments = attachField1.Attachments
For each attachment in theAttachments
     set thefileName = attachment.FileName 
     set thefileSize = attachment.FileSize 
     currentSession.OutputDebugString "Attached file: " & _
          thefileName & " - size: " & thefileSize 
Next

Perl

# This example assumes that there is at least 1 attachment
# field associated with the record. Otherwise, 
# GetAttachmentFields won't return anything interesting
# and an error would be generated

# Get the collection of attachment fields
$attachfields = $entity->GetAttachmentFields();

# Get the first attachment fields
$attachfield1 = $attachfields->Item(0)

# Now get the collection of attachments from the attachments field
$attachments = $attachfield1->GetAttachments();

# Retrieve the number of attachments for the for loop
$numattachments = $attachments->Count();

for ($x = 0 ; $x < $numattachments ; $x++)
 {
   # Retrieve the correct attachment
   $attachment = $attachments->Item($x);

   # Get the filename and filesize for the attachment and print out
   # the results
   $filename = $attachment->GetFileName(); 
   $filesize = $attachment->GetFileSize();
   $session->OutputDebugString("Attached file: ".$filename." - 
          size: ".$filesize);
 } 

Feedback