Copy files to shared folder in LAN

T

tienlx

Hi all,
I want to copy files to shared folder to another computer in Local
area network. Although, Ba-hcm\Administrator have full access
permission to that folder, but it always throws "Access denied"
error.


Is anything wrong?

thanks,
tle

UploadShared(myfile,"\\HCM-CTL2\DATA");

private static bool UploadShared(SPFile file, string destUrl)
{

Uri destUri = new Uri(destUrl);

WebRequest req = WebRequest.Create(destUri);
req.Method = "PUT";
req.Headers.Add("Overwrite", "F");
req.Timeout = System.Threading.Timeout.Infinite;

string SecurelyStoredUserName = "Administrator";
string SecurelyStoredPassword = "";
string SecurelyStoredDomain = "BA-HCM";

CredentialCache myCache = new CredentialCache();

myCache.Add(destUri, "Basic", new
NetworkCredential(SecurelyStoredUserName, SecurelyStoredPassword));
myCache.Add(destUri, "Digest", new
NetworkCredential(SecurelyStoredUserName, SecurelyStoredPassword,
SecurelyStoredDomain));
myCache.Add(destUri, "Negotiate", new
NetworkCredential(SecurelyStoredUserName, SecurelyStoredPassword,
SecurelyStoredDomain));
myCache.Add(destUri, "Kerberos", new
NetworkCredential(SecurelyStoredUserName, SecurelyStoredPassword,
SecurelyStoredDomain));
myCache.Add(destUri, "NTLM", new
NetworkCredential(SecurelyStoredUserName, SecurelyStoredPassword,
SecurelyStoredDomain));


req.Credentials = myCache;

Stream ToStream = req.GetRequestStream(); // <= throw
error here !

/* stream copy */
Stream FromStream = file.OpenBinaryStream();
bool status = CopyStream(FromStream, ToStream);


return status;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top