SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a schema that I have added to my Sequential Workflow solution. Currently, when I access the schema it is hard coded to a location on my c drive.

doc.Schemas.Add(@"", @"C:\Code\NSI\xsd\lexs\publish-discover\3.1\publish-discover.xsd");

I would like to upload this schema to a library for future use. However, this sequential workflow has to be used on many different computers, all of which will not contain the schema in the location that I have on my computer. So I added the schema to my workflow project but when I try to call on it using a relative path with the following code:

doc.Schemas.Add(@"", @"..\Schemas\publish-discover.xsd");

I get the error: "c:\windows\system32\Schemas\publish-discover.xsd". I want to be able to access the schema without having to provide a local hard coded path so I can upload it to a library and have the final wsp file work on multiple machines.

share|improve this question
Basically I am trying to access a file, any file, that I have added to my solution, but when I type in the path "../folder/file.xsd" Visual Studio defaults to the c:\windows\system32 folder. I want to know how to add a file to my solution and access it without having provide a path from the local hard disk. – Meyer Denney Jun 10 '11 at 20:40
up vote 1 down vote accepted

You can include the schema as an embedded resource in your solution. Then using Properties.Resources.WhateverYouNameTheResource you can open it in code. This way the schema will get deployed with your assembly. More on embedded resources here:

share|improve this answer
Thank you I tried that and it worked, but it returned a string of the schema. When I try to access the schema with this line of code doc.Schemas.Add(@"ijis-isesar/1.5";, NSI_FCS_Workflow.Properties.Resources.sari); it throws an exception stating it wants a url to the path of the schema rather then the schema in string form. To get around this I passed the string to the a StringReader and then passed that to an XmlReader and it worked great. – Meyer Denney Jun 13 '11 at 18:06

You can provision the file into a document library and refer the file via path which is common for all users. You can do this via in your feature's element file. Example below:

share|improve this answer
Thank you, I tried that, and the file is there, but when I try to access it with code doc.Schemas.Add(@"ijis-isesar/1.5";, @"yak/NSI_FCS_Bin/sari.xsd"); I get a 401 Unauthorized error. However, if I type the address into IE, I can access the file just fine and it prompts me to download it. Is there something else I have to do to get around the 401 error? I made sure I was logged in before running the code. – Meyer Denney Jun 13 '11 at 16:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.