Search code examples
c#wcfwcf-binding

Issue while reading a xml file in WCF service


WCF service has one method ( Let's say TestMethod) in which I try to create a File Stream like this :

            System.IO.FileStream fs = new System.IO.FileStream(@"D:\Test.xml", System.IO.FileMode.Open);

My Client and Service is on the same solution.

When the Client makes a call to TestMethod ( Exposed in Web service ) it will give this error:

Access to the path 'D:\DXDirectoryAuth.xml' is denied.

Please Help!!


Solution

  • Have you tried:

    System.IO.FileStream fs = new System.IO.FileStream(@"D:\Test.xml", System.IO.FileMode.Open, System.IO.FileAccess.Read);
    

    The default constructor of FileStream() asks for read and write access.