473,788 Members | 2,856 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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\Administrat or have full access
permission to that folder, but it always throws "Access denied"
error.
Is anything wrong?

thanks,
tle

UploadShared(my file,"\\HCM-CTL2\DATA");

private static bool UploadShared(SP File file, string destUrl)
{

Uri destUri = new Uri(destUrl);

WebRequest req = WebRequest.Crea te(destUri);
req.Method = "PUT";
req.Headers.Add ("Overwrite" , "F");
req.Timeout = System.Threadin g.Timeout.Infin ite;

string SecurelyStoredU serName = "Administrator" ;
string SecurelyStoredP assword = "";
string SecurelyStoredD omain = "BA-HCM";

CredentialCache myCache = new CredentialCache ();

myCache.Add(des tUri, "Basic", new
NetworkCredenti al(SecurelyStor edUserName, SecurelyStoredP assword));
myCache.Add(des tUri, "Digest", new
NetworkCredenti al(SecurelyStor edUserName, SecurelyStoredP assword,
SecurelyStoredD omain));
myCache.Add(des tUri, "Negotiate" , new
NetworkCredenti al(SecurelyStor edUserName, SecurelyStoredP assword,
SecurelyStoredD omain));
myCache.Add(des tUri, "Kerberos", new
NetworkCredenti al(SecurelyStor edUserName, SecurelyStoredP assword,
SecurelyStoredD omain));
myCache.Add(des tUri, "NTLM", new
NetworkCredenti al(SecurelyStor edUserName, SecurelyStoredP assword,
SecurelyStoredD omain));
req.Credentials = myCache;

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

/* stream copy */
Stream FromStream = file.OpenBinary Stream();
bool status = CopyStream(From Stream, ToStream);
return status;
}

Jul 27 '07 #1
1 11898
UploadShared(my file,@"\\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
2599
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, for the questions. 1. A button on my control executes the System.IO.Directory.GetDirectories funtion (the scanned directory resides on the hosting web server). What credentials is this
1
2415
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 does not cause the files to be shared as well. How can I make the moved files inherit the parent folder's shared setting? I have looked into the System.Security.Permissions.FileIOPermission class but it doesn't seem to do what I'm looking for. I'm...
8
17039
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 with '\\' it doesnt work and exception is thrown (for example: \\MyComputer\DestDirectory). Even if the first and the second directories are actually the same- the File.Copy() doesn't work. Is there any way to copy a file to a different computer?...
3
2932
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 written a windows service as part of an interface between two different systems. The first system will write output into a file in a
2
3687
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 it? Anybody can help me?
2
2798
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 created). It also reads another registry key for another path which is a destination path. When a file shows up, it copies it off. It actually works well . . . For small duty stuff but if for example I were to copy in multiple small files...
0
1206
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, it watches a folder that is set in a registry key, and if there is a file created in that folder, it copies it to a destination folder, also defined in a registry key. This works fine, for individual files, and small files, but as mentioned...
1
3898
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 a single folder called 'All Files' Do we spread them out and copy them to multiple folders like Folder 000 - Copy files from 0 to 1000 Folder 001 - Copy files from 1000 to 2000 Folder 002 - Copy files from 2000 to 2999
2
6038
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 an error "Access is denied". I tried the same code in Windows application and it worls fine. The problem is present only in the Windows Service. Any suggestions?
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10177
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5403
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.