Load

설명

이 오브젝트의 컨텐츠를 지정된 파일에 씁니다.

이 메소드를 사용하여 데이터베이스에서 첨부 파일을 추출한 후 이를 로컬 파일 시스템에 저장합니다. filename 매개변수에 지정된 경로에 동일한 이름을 가진 파일이 이미 존재하면 파일은 쓰기 가능해야 하며 기존 컨텐츠를 겹쳐쓰게 됩니다. 추출된 파일은 임시 파일이 아닙니다. 이 파일은 해당 API를 사용하는 프로세스가 종료될 때까지 존재합니다.

구문

VBScript

attachment.Load filename 

Perl

$attachment->Load(filename); 
ID
설명
attachment
파일을 레코드에 첨부함을 나타내는 Attachment 오브젝트입니다.
filename
쓸 파일의 경로 이름을 포함하는 문자열입니다. 이 경로 이름은 절대 경로 또는 상대 경로일 수 있습니다.
Return value
오퍼레이션이 완료된 경우에는 값이 True, 실패할 경우에는 False인 부울입니다.

예제

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 
x = 1
For each attachment in theAttachments 
   thefileName = "C:\attach" & x & ".txt" 
   x=x+1
' Write the file
   status = attachment.Load (thefileName)
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);

 # Select a filename to write to
 $filename = "C:\\attach".$x.".txt";

 # Write the file
 $status = $attachment->Load($filename);
 } 

피드백