Showing posts with label Content Files. Show all posts
Showing posts with label Content Files. Show all posts

Wednesday, June 9, 2010

XBAP – content files

 

Test the difference between these and explain was the different “Build Action”’s do to these types of loading

// In project itself = "same directory on the server as my .xbap file"  
Uri uri = new Uri("pack://siteoforigin:,,,/StorageSCP.ass.xml");
// In project itself = compiled into main exe  
Uri uri2 = new Uri("pack://application:,,,/StorageSCP.ass.xml");
// In project itself = included as "loose content"  
Uri uri3 = new Uri("StorageSCP.ass.xml", UriKind.Relative);
StreamResourceInfo assXML = Application.GetRemoteStream(uri);
StreamResourceInfo assXML3 = Application.GetRemoteStream(uri3);
StreamResourceInfo assXML2 = Application.GetContentStream(uri2);

 

Also see what this does ?

Application.GetResourceStream(uri)

Wednesday, April 28, 2010

XBAP - SiteOfOrigin Files

 

I used this little snippet after a couple of hours hunting MSDN forums

StreamResourceInfo f = Application.GetRemoteStream(new Uri("pack://siteoforigin:,,,/"+fileSolutionPath));

//f.Stream //to your IO with this

Note: siteoforigin files are downloaded from the host on demand, so should be downloaded as needed.

Cool little beasty

http://msdn.microsoft.com/en-us/library/aa970494.aspx#Site_of_Origin_Files

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/9df060ca-019e-4443-8167-ccf511a73f84

I actually used this to copy some configuration files, DICOM Server Association files, to my Full Trusted XMAP home. I had made the Full Trust XMAP home (Environment.CurrentDirectory) a Temp folder i.e. System.IO.Path.Combine(System.IO.Path.GetTempPath(), "MyAppName") and needed to get the association list for a Storage SCP.

Thus

f.Stream.CopyTo((File.OpenWrite(Path.Combine(Environment.CurrentDirectory, fileSolutionPath))));