Download file in silverlight

I would like to upload a custom file placed as a resource file in a silverlight application, but FileStream does not work (since I have to stay in a partial trust environment).

Is there any solution to upload my file? (this is binary serialized data).

UPDATE Answer found:

  • I placed my file as a “resource” (I did not insert content or anything else)
  • Download it as follows:

    StreamResourceInfo info = Application.GetResourceStream (new Uri (@ "/ Utilitaires; component / Resources /" + name, UriKind.Relative));

And then using the "info.Stream" property.

Now I have another question. By doing so, the file is added to the assembly (in exe / dll) and makes it a little larger.

But since this data needs to be loaded simultaneously with the assembly, should I allow it as a resource or use another method to separate it separately? (and what should be the method? I need it to work on both the local and the server).

Thank,

Kite

+3
source share
1 answer

Since you need the resource while loading the assembly, the only reason you need to place the file outside of Xap is to allow the file to be modified without changing Xap.

Personally, I would include the file as "Content" rather than "Resource". This means that the file ends as an entry in Xap (which is only a Zip file), and not inside the dll.

GetResourceStream , Url - : -

new Uri(@"/Assets/" + name, UriKind.Relative)

Assets - , , .

. Xap, - , Xap Zip , .

0

Source: https://habr.com/ru/post/1772177/


All Articles