2015-12-03 40 views
0

我目前正在使用C#,WCF和azure存儲的Web服務。我需要做一個上傳方法,但是我有一個上傳文件路徑的問題。事實上,我無法傳入參數路徑文件,它總是在方法中返回null,我該如何處理?這裏的代碼:C#/ WCF傳入參數文件路徑

public void uploadFiles(string path, string ContainerName) 
{ 
    // Connect to the storage account's blob endpoint 
    CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString")); 
    CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); 

    // Create the blob storage container 
    CloudBlobContainer container = blobClient.GetContainerReference(ContainerName); 
    container.CreateIfNotExists(); 

    // Create the blob in the container 
    CloudBlockBlob blob = container.GetBlockBlobReference("name"); 

    using (var fileStream = System.IO.File.OpenRead(path)) 
    { 
     blob.UploadFromStream(fileStream); 
    } 
} 

字符串路徑是直接爲空,所以我不能添加@。

+0

你的情況下'path'的值是什麼..?你可以告訴我們..? – MethodMan

+0

如果'path'爲空,檢查地方,你打電話'uploadFiles(...)' –

+0

請不要「謝謝每次進展」,*絕對請*停止在底部添加簽名。我們不這樣做。此外,**你的名字和頭像已經在你的文章底部**。欲瞭解更多信息,請查看[meta]。 – Will

回答

2

您正在傳遞從遠程客戶端到您的服務的路徑。該路徑將位於客戶端上的文件中。您無法在服務器上打開該路徑。

要上傳文件,您必須傳遞實際的文件數據。

+0

通過WCF傳輸文件在最好的情況下是有問題的,在最壞的情況下則是滑稽的。 –