0

I want to access path with following code however, it throws and error

IOException: The user name or password is incorrect
System.IO.FileStream.OpenHandle(FileMode mode, FileShare share, FileOptions 
options)

I use the following code

var filePath = "\\\\172.x.x.x\\UploadFolder";
using (var stream = new FileStream(filePath, FileMode.Create)
{
    await files.First().CopyToAsync(stream);
}

How can I setup user name and password in this case?

EDIT:

as from the comment below I have searched and try again with this method:

bool returnValue = LogonUser("TestDomain\\testAccount", "172.x.x.x", "testPassword",
            LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT,
            out safeTokenHandle);
// I've tried both TestDomain\\testAccount and TestDomain/testAccount

it's always return false. when I test it with my computer it's return true though.

bool returnValue = LogonUser("admin", "127.0.0.1", "password",
            LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT,
            out safeTokenHandle);

Is the problem happens because of domain server or something?

Akore
  • 65
  • 3
  • 8
  • Maybe, you don't have the right to access the shared directory (file on a Universal Naming Convention (UNC) share)! – Am_I_Helpful Sep 11 '17 at 03:31

1 Answers1

-1

This problem occurs because you dont have privilage to access or make changes to that directory. Change your directory to other drives( if it is possible). Or run your program with administrator privilage. May it will help