JumpyStackOverflow
JumpyStackOverflow

Reputation: 720

Localized file resource not found

I have included these files in my project with Build Action set to Content:

\Resources\Myfolder\Myfiles-de-DE.zip
\Resources\Myfolder\Myfiles-en-US.zip
\Resources\Myfolder\Myfiles-sv-SV.zip
\Resources\Myfolder\Myfiles-fr-FR.zip

In my Package.appxmanifest I have tried this [when "Open With..." "XML (Text) Editor"]:

  <Resources>
    <!--  First = Default  -->
    <Resource Language="en-US" />
    <Resource Language="sv-SV" />
    <Resource Language="de-DE" />
    <Resource Language="fr-FR" />
  </Resources>

and this:

  <Resources>
    <Resource Language="x-generate" />
  </Resources>

In code I am trying to access the file like this:

Dim ZipPath As String = "Resources\Myfolder\Myfiles-.zip"
Dim fs As System.IO.Stream = Await _    
Windows.ApplicationModel.Package.Current.InstalledLocation.OpenStreamForReadAsync(ZipPath)

But I get only a FileNotFoundException! What am I doing wrong?

PS: The file loads if I change the code to this:

Dim ZipPath As String = "Resources\Myfolder\Myfiles-en-US.zip"

Upvotes: 1

Views: 383

Answers (1)

Chubosaurus Software
Chubosaurus Software

Reputation: 8161

It isn't fully clear what you're trying to accomplish. But the code should throw that exception unless you have Resources\Myfolder\Myfiles-.zip file loaded in there by default.

I'm guessing you want to load in the specific zip file based on their prefer language, but no where in your code do attempt to get their language.

You can try to do a LocalizedStrings : How to build a localized app for Windows Phone 8

Or you can just get their prefer language and append it to the ZipPath that you have

string ZipPath = "Resources\Myfolder\Myfiles-" + culture_extention + ".zip";

where culture_extention is Windows.System.UserProfile.GlobalizationPreferences.Languages[0]

enter image description here

Upvotes: 1

Related Questions