473,387 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Copy files to shared folder in LAN

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;
}

Jul 27 '07 #1
1 11865
UploadShared(myfile,@"\\HCM-CTL2\DATA");

Jul 27 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tess | last post by:
Hi, Long time reader, first time poster... Any help is appreciated. I have a few questions regarding Winform controls embedded within an html page. For more info please see the appendix. Now,...
1
by: Hubert Wong | last post by:
Hi, I am writing some C# code that moves files from a source folder to a target folder on the same machine. However, if the target folder is a shared folder, using the File.MoveTo method alone...
8
by: Ram Baruch | last post by:
Hi, I'm trying to use the File.Copy() function. It works well when the desenation file is local (Like: C:\dest\dest.exe). The problem is that when I'm trying to copy to a destenation that starts...
3
by: News | last post by:
Is it possible to delete a file by copying it to the "bit bucket" or "null device"? Back in my youth when I live in VMS-land you could delete a file by copying it to NL: ========== I have...
2
by: Dámaso Velázquez Álvarez | last post by:
Hi, I need to copy files to a shared folder protected by username/password. I don't now autenticate me in the server to copy the files. Do I need to use the credentials to do it? How can i do...
2
by: TwistedPair | last post by:
All, This is sort of a continuation of a previous post of mine. The code below basically reads a registry key to get a path to a folder and it watches for files created in that folder (only...
0
by: TwistedPair | last post by:
All, I had some great advice about this a bit ago, but I'm just not good enough with this code to put together all the pieces. The way the code below works is as a service. When it is started,...
1
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
Using .NET 2.0 is it more efficient to copy files to a single folder versus spreading them across multiple folders. For instance if we have 100,000 files to be copied, Do we copy all of them to...
2
by: sebouh181 | last post by:
Hi, I have a Windows Service that copies xml files from a shared folder on the server. I am using System.IO.File.Copy(\\Server-Name\SharedDir) method. But whenever I try to copy files there is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.