kiran kumar
kiran kumar

Reputation: 63

How to Acess the Path of a file in Resources subfolder (Xamarin.Android)

I have EnglishSD.nbin file in Resources sub Models_folder I am accessing the path like this in my xamarin.android project but I am getting file not found Please help me with your suggestions thanks

enter image description here

var modelPath = AppDomain.CurrentDomain.BaseDirectory + "D:\\Foldername\\Project Name 
                                                               \\Resources\\Models\\EnglishSD.nbin";

            var sentenceDetector = new EnglishMaximumEntropySentenceDetector(modelPath);
            var sentences = sentenceDetector.SentenceDetect(paragraph);
            return sentences;

Error

Error: File not found Error

Upvotes: 0

Views: 691

Answers (1)

JDG
JDG

Reputation: 36

I'm not familiar with a ".nbin" file, but I would recommend putting it in the Android Assets folder instead.

enter image description here

You can read files from Assets like this:

public async Task<byte[]> ReadPdfFileAsync()
{
    using (var fileStream = Assets.Open("pdf-file.pdf")
    using (var memoryStream = new MemoryStream())
    {
        await fileStream.CopyToAsync(memoryStream);
        return memoryStream.ToArray();
    }
}

Upvotes: 1

Related Questions