2013-02-18 1 views
2

내 응용 프로그램에서 Azure blob 저장소에 문서를 업로드하려고합니다. 코드는 다음과 같습니다CreateIfNotExists의 네임 스페이스 란 무엇입니까?

// Namespaces for Azure 
using Microsoft.WindowsAzure; 
using Microsoft.WindowsAzure.StorageClient; 

public ActionResult GetPdf(HttpPostedFileBase document) 
{ 
    int pdfocument = Request.ContentLength; 

    var doctype=Request.ContentType; 

    byte[] pdf = new byte[pdfocument];    
    CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("Setting1")); 
    CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();   
    CloudBlobContainer container = blobClient.GetContainerReference("containername"); 
    container.CreateIfNotExists(); 
    var permissions = container.GetPermissions(); 
    permissions.PublicAccess = BlobContainerPublicAccessType.Blob; 
    container.SetPermissions(permissions); 
    string uniqueBlobName = "blobname"; 
    CloudBlockBlob blob = container.GetBlockBlobReference(uniqueBlobName); 
    blob.Properties.ContentType = doctype; 
    blob.UploadByteArray(pdf); 
} 

내 응용 프로그램을 빌드 할 때 내가 container.CreateIfNotExists()에서 오류가 발생합니다. 오류 :

'Microsoft.WindowsAzure.StorageClient.CloudBlobContainer은'CreateIfNotExists '유형'Microsoft.WindowsAzure.StorageClient.CloudBlobContainer '의 첫 번째 인수를 받아들이는'CreateIfNotExists '에 대한 정의없이 확장 메서드가 포함되어 있지 않습니다 찾을 수 있습니다 (사용 지시문이나 어셈블리 참조가 누락 되었습니까?) '.

어떤 오류가 발생하여 해당 오류를 추가 할 수 있습니까?

답변

7

CreateIfNotExists는 Azure 라이브러리 버전 2.0의 일부입니다.

당신이 CreateIfNotExist (NO 복수)를 호출 할 필요가 다음 버전 1.7 StorageClient 네임 스페이스를 사용하는 경우

+0

안녕 롭, 귀하의 정보 hours.Thanks의 correct.it의이 오전 충분했을 매우 usefult 낭비 커플이다 제비. – PCSSCP

+0

@PCSSCP, 귀하의 질문을 해결 한 경우 대답으로 표시하십시오. –

+0

페르난도, 지금 표시했습니다. – PCSSCP