Hi,
I would like to know if I code it correctly. To upload file manually to my workplace server, I have to use Login ID and Password. With the clode below, should I include my loginID and Password as well?
public void SaveLogsToWeb(string logFileName)
{
WebClient webClient = new WebClient();
string webAddress = null;
try
{
webAddress = @"http://myCompany/ShareDoc/";
webClient.Credentials = CredentialCache.DefaultCredentials;
WebRequest serverRequest = WebRequest.Create(webAddress);
WebResponse serverResponse;
serverResponse = serverRequest.GetResponse();
serverResponse.Close();
webClient.UploadFile(webAddress + logFileName, "PUT", logFileName);
webClient.Dispose();
webClient = null;
}
catch (Exception error)
{
MessageBox.Show(error.Message);
}
}
When I run it, exception throws "(401) Unauthorized"
thanks.