I'm trying to have my web service write to a shared drive on our intranet. I'm getting an IOException on my StreamWriter
string fullpath = path + "\\" + fileName;
using (System.IO.StreamWriter file = new System.IO.StreamWriter(fullpath, append))
{
file.WriteLine(contents);
file.Close();
}
And the exception I'm seeing,
IOException - Logon failure: unknown user name or bad password
If I'm understanding correctly, the user of the IIS web server needs to have access to write to the shared drive. I'm wondering if there's a way I can hard-code credentials for now, to write to the shared drive for debugging purposes. How can I provide credentials to a StreamWriter, or is there another mechanism I should be using?
I looked into Impersonation (using StreamWriter on server in C#) and would like to use that as a last resort if possible.