Question: Im developing a WCF web service with receives always and only XML.

So i need to validate that input XML using their XSD. The question is, can i save them inside web service? Locally i can access XSD files via relative path into IIS Express root folder which i created manually. I tried add the XSD files in VS project but i just cant a find them on runtime.

I'm using the Shemas like this: [Image1 Link](http://s16.postimg.org/cmnm850lh/image.png)

IIS XSD'd Folder Path Workaround: [Image2 Link](http://i.stack.imgur.com/ePozA.png)

At the moment, its working fine, the problem will be when i try deploy the service somewhere on internet.  

Thank you.

**tl;dr: Can i send some XSD when deploying the webservice or its just impossible?**

Answer: 
Files that belong to your solution should be **physically** part of it. Once that is the case you can use for instance [`HostingEnvironment.MapPath`](http://msdn.microsoft.com/en-us/library/system.web.hosting.hostingenvironment.mappath%28v=vs.110%29.aspx); or look at the answers to [this question](https://stackoverflow.com/questions/791468/how-to-get-working-path-of-a-wcf-application). Note that there is [a possible issue](http://blogs.msmvps.com/theproblemsolver/2009/02/08/gotcha-with-hostingenvironment-mappath/) with HostingEnvironment.MapPath when the WCF service is self hosted.

A possible solution is this method:

```
public static string MapPath(string path)
{
    if (HttpContext.Current != null)
        return HttpContext.Current.Server.MapPath(path);

    return HostingEnvironment.MapPath(path);
}

```

The parameter `path` needs to be of the format `"~/XSD/MyFile.xsd"`, with the folder "XSD" being located in the root of your WCF service.

NEVER create folders in `c:\program files (x86)\iis express`.
One way you can do it is by using an application setting in your config file that will hold a base file location such as:

```
<appSettings>
    <add key="BaseDir" value="C:\your\folder\names" />
</appSettings>

```

Then in your program, when you need a file, you would do something like this:

```
string fileLocation = System.Configuration.ConfigurationManager.AppSettings["BaseDir"] +
                           @"\your\file\location\file.xsd";

```

To use `System.Configuration.ConfigurationManager`, you will need to add a reference to `System.Configuration`.