© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•11mo ago•
5 replies
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);
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.'
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
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,828Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Upload large files to azure storage!
C#CC# / help
3y ago
Load files from azure at startup and add new files in memory and azure storage
C#CC# / help
2y ago
❔ Content reading from azure storage!
C#CC# / help
3y ago
✅ azure file storage
C#CC# / help
2y ago