views:

41

answers:

2

I am working on Windows Azure. I followed some tutorial about how to store text file on to the blob of windows azure. I am successful in uploading the data. Now, I wanted to access the file. I mean, I have to read the content of the file and display it....

Can anyone tell me, How to do that...

Thanks, in advance...

A: 

Use DownloadText(): http://msdn.microsoft.com/en-us/library/ee772911.aspx

smarx
A: 

        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);
    }
Egon