tags:

views:

36

answers:

1

Hello,

I'd like to create WCF operation contract which consumes a string, produces a public webpage and then returns the address of this new page.

[ServiceContract(Namespace = "")]
public class DatabaseService
{
    [OperationContract]
    public string BuildPage(string fileName, string html)
    {

        //writes html to file
        //returns public file url

    }
}

This doesn't seem like it should be complicated but i cant figure out how to do it. So far what i've tried is this:

[OperationContract]
public string PrintToFile(string name, string text)
{
    FileInfo f = new FileInfo(name);
    StreamWriter w = f.AppendText();
    w.Write(text);
    w.Close();
    return f.Directory.ToString();
}

Here's the problem. This does not create a file in the web root, it creates it in the directory where the webdav server is running. When i run this on an IIS server it seems to do nothing at all (at least not that i can tell). How can I get a handle to the webroot programmatically so that i can place the resultant file there and then return the public URL? I can tack on the domain name after the fact without issue so if it only returns the relative path to the file that's fine.

Thanks, brian

A: 

Why do you need to programatically determine the path, don't you know the it? Can't you just put it in a config file and read it from there?

Ben Robinson
I suppose i could but id rather not. The app is intended to be deployed in a variety of places and anything that reduces the amount of config files that need to be changed by me is pretty awesome.
sweeney