Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detecting .doc and .xls file using the StreamExtensions or ByteArrayExtensions #25

Open
melucas opened this issue Oct 2, 2018 · 0 comments

Comments

@melucas
Copy link

melucas commented Oct 2, 2018

When loading a old Microsoft Office file into a stream or byte array, the GetFileType() resulting MimeType is doc,ppt,xls, not the expect xls or doc.

For example. Both text fail.

    [Fact]
    public void CanReadExcelFileFromByteArray()
    {
        var result = File.ReadAllBytes("./data/Documents/XlsExcel2007.xls").GetFileType();

        Assert.NotNull(result);
        Assert.Equal(MimeTypes.EXCEL, result);
    }

    [Fact]
    public void CanReadExcelFileFromStream()
    {
        using (FileStream stream = File.Open("./data/Documents/XlsExcel2007.xls", FileMode.Open))
        {
            var result = stream.GetFileType(false, true);

            Assert.NotNull(result);
            Assert.Equal(MimeTypes.EXCEL, result);
        }
    }

Any ideas how to get this to work without having to save the files to disk and then loading them using the FileInfo object?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant