C#C
C#9mo ago
Buck3tt

Fetching XML files from Azure Storage Explorer sometime fails

So for work we have a Azure Storage Explorer Fileshare where the customer sends XML files. Our Job fetches files from this fileshare every ~20 minutes maybe. Some files works fine and some just straight up fails with this code
var xmlFileByteArray = _azureHelper.GetFileBytes(fileName, sourceDirectory);

if (xmlFileByteArray is null)
{
    return;
}

var reader = new StreamReader(new MemoryStream(xmlFileByteArray));
var xmlDocument = new XmlDocument();
xmlDocument.Load(reader);

And xmlDocument just says
System.Xml.XmlException: 'Data at the root level is invalid. Line 1, position 1.'


The weird part is, when I locally debug it, fetch the correct file and run the same code, it doesn't fail.

How could this be?
They are named "123-1345.xml" or similar in the share and looks fine in notepad ++ or whatever program.

Could there be some sort of "buffer" time that the file hasn't fully transformed in to a xml file yet or similar?

Any help is appriciated
Was this page helpful?