I need to save file on a unc location using .net core web api. The location could be accessed with correct username & password combo. Following piece of code does not work, I mean when I try to create directory.I am afraid I am not passing username and password correct way. Could someone look into this please.
try
{
var credential = new NetworkCredential("username", "password", "\\\\location\\Test");
var testCache = new CredentialCache
{
{ new Uri("\\\\location\\test"), "Basic", credential }
};
var folder = GetDestinationFolder(DateTime.Now, "\\\\location\\test");
Directory.CreateDirectory(folder); // it throws exception saying access to the path is denied
}
catch (Exception ex)
{
var exxx = ex.Message;
}