Retrieving Additional Files in LightSwitch

I want to add additional files (mainly .xlsxand .docx) to the LightSwitch application and use these files in the application, for example, as a stream.

What is the best way / practice for this?

So far I can add files to the client project (under the file view). This file is then displayed in the directory bin\debug\bin\Serverwhen I do a debug build or publish an application. So now comes the hard part.

How to get a stream of files from these files?

In which directory is it installed?

+1
source share
1 answer

. , .

-, " ", , :

// get the currently executing assembly
Assembly assembly = Assembly.GetExecutingAssembly();

// list all available ResourceName's
string[] resources = assembly.GetManifestResourceNames();

// creates a StreamReader from the TestFile.txt
StreamReader sr = new StreamReader(assembly
            .GetManifestResourceStream("LightSwitchApplication.TestFile.txt"));

// puts the content of the TestFile.txt in a string
string text = sr.ReadToEnd();
+1

All Articles