Problem with MFC CopyFile(sourcefile, destfile, FALSE)

Hi, I am trying to copy file from a local directory to a server directory..But I face a problem where the server directory folder is require username and password to access it..

Anyone know how to copy file into password protected folder??

Thanks.

NETRESOURCE nr;
DWORD res;
DWORD dwFlags;

nr.dwType=RESOURCETYPE_DISK;
nr.lpLocalName = NULL;
nr.lpProvider = NULL;

USES_CONVERSION;
CString sPath;

LPWSTR wide = W2A(sPath.GetBuffer(0));
nr.lpRemoteName = wide;
sPath.ReleaseBuffer();

dwFlags = CONNECT_UPDATE_PROFILE;
res = WNetAddConnection2(&nr, _T("123"), _T("123"), dwFlags);

After i compile, i get error like this:
error C2440: 'type cast' : cannot convert from 'ATL::CSimpleStringT<BaseType,t_bMFCDLL>::PXSTR' to 'ATL::CW2AEX<>'
No constructor could take the source type, or constructor overload resolution was ambiguous

My sPath is a string return from other function, so i need to convert it be LPWSTR, but i cant figure out why there is an error occur at the convertion part.
Anyway, I guess i fix the upper problem already..But i facing new error:
error LNK2019: unresolved external symbol _WNetAddConnection2A@16 referenced in function "public: void __thiscall CPackage_UploaderDlg::OnBnClickedButtonUpload(void)" (?OnBnClickedButtonUpload@CPackage_UploaderDlg@@QAEXXZ)

does I need to declare WNetAddConnection2 in my header file?
You need to link against mpr.lib. See the function's documentation (the link I gave you).
Topic archived. No new replies allowed.