2010-04-07 130 views
1

我正在使用Windows Azure。我遵循了一些關於如何將文本文件存儲到Windows azure blob的教程。 我成功上傳數據。現在,我想訪問該文件。我的意思是,我要讀文件的內容,並顯示它....訪問存儲在Windows Azure BLOB上的文本文件

誰能告訴我,那怎麼辦?

感謝,提前 ...

回答

0

 public CloudBlobContainer ContBlob; 

    public string UpFile(string FilePathName, string bName, NameValueCollection nM) 
    { 
     string s1; 
     FileStream F1 = new FileStream(FilePathName, FileMode.Open, FileAccess.Read);    
     ContBlob.GetBlobReference(bName).UploadFromStream(F1); 
     s1 = ContBlob.GetBlobReference(bName).ToString();  
     ContBlob.GetBlobReference(bName).Metadata.Add(nM); 
     F1.Close(); 
     return s1; 
    } 


    public NameValueCollection DownFile(string FilePathName, string bName) 
    { 
     NameValueCollection nM = new NameValueCollection(); 
     FileStream F1 = new FileStream(FilePathName, FileMode.Create, FileAccess.Write); 
     ContBlob.GetBlobReference(bName).DownloadToStream(F1); 
     nM = ContBlob.GetBlobReference(bName).Metadata; 
     F1.Close(); 
     return nM; 
    } 

    public NameValueCollection DownMeta(string bName) 
    { 
     NameValueCollection nM = new NameValueCollection(); 
     nM = ContBlob.GetBlobReference(bName).Metadata; 
     return nM; 
    } 

    public void UpMeta(string bName, NameValueCollection nM) 
    { 
     ContBlob.GetBlobReference(bName).Metadata.Clear(); 
     ContBlob.GetBlobReference(bName).Metadata.Add(nM); 
    }