خرید بک لینک

Vote count: 0

I am working on a project that is reading the data from a Azure Blob and saving that data into an Object. I am currently ruing into a problem. The way my code is set up now - it will read all the .txt data within a container if there are no Virtual Folders present.

However, if there is a virtual folder structure present within a Azure Container my code will error out, with a NullExceptionReference. My idea was to do a if check to see if there was Virtual Folders present within an Azure Container if so execute //some code. Is there a way to tell if there is a virtual folder is present?


RetuBlobObject()

private List<Blob> RetuBlobObject(O365 o365)
    {
        List<Blob> listResult = new List<Blob>();
        string textToFindPatte = "(\/)";
        string fileName = null;
        string content = null;

        //Loop through all Blobs and split the container form the file name.
        foreach (var blobItem in o365.Container.ListBlobs(useFlatBlobListing: true))
        {
            string containerAndFileName = blobItem.Parent.Uri.MakeRelativeUri(blobItem.Uri).ToString();
            string[] subString = Regex.Split(containerAndFileName, textToFindPatte);

            //subString[2] is the name of the file.
            fileName = subString[2];
            content = ReadFromBlobStream(o365.Container.GetBlobReference(subString[2]));

            Blob blobObject = new Blob(fileName, content);

            listResult.Add(blobObject);
        }

        retu listResult; 
    }

ReadFromBlobStream

    private string ReadFromBlobStream(CloudBlob blob)
    {
        Stream stream = blob.OpenRead();
        using (StreamReader reader = new StreamReader(stream))
        {
            retu reader.ReadToEnd();
        }
    }

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 4 ارديبهشت 1395 ساعت: 1:55

صفحه بندی