简体   繁体   中英

C# access files from another project

I am having a solution consisting on silverlight and web project. i want to access a file which is located inside a folder in web project from my silverlight project.how can this be done.

this file is a users manual document for which i have to provide the download functionality to the user..

Right click on the Silverlight project and select Add --> Existing item. In the dialog, navigate to the location of the web project. Select the file(s) you need but instead of clicking on "Add", click on the dropdown next to the Add button and select "Add As Link".

In your Silverlight project:

  1. Right-click References > Add Reference.
  2. On the left tab, select Solution.
  3. Select which project(s) you want to include a reference to.

In Silverlight project C# files, you may have to add a 'using' statement if you are trying to use a Class from a referenced project.

Got the solutions as below,

var uri = new Uri(Application.Current.Host.Source, "../DirectoryName/FileName.docx"); 
HtmlPage.Window.Navigate(uri);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM