473,563 Members | 2,916 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Uploading a File on a shared documents folder programatically

All

I'm having trouble getting the following to work. I have been able to
download and delete a file with the same credentials and similar code,
but when I try upload the file. I get a returned error of "The Remote
server returned an error: (500) Internal Server Error." from the SPS.

Is there something that must be set up on SPS to allow a "PUT" or am I
missing something.
I am using very similar code to delete and download a file from the
same folder on the SPS. And its all working perfectly

Uri MSURI = new
Uri("https://DomainName.co.u k/Shared%20Docume nts/test/Test.txt");
NetworkCredenti al MSCred= new
NetworkCredenti al(MSUserID,MSP assword,MSDomai n);
HttpWebRequest MSHttpWebReques t
=(HttpWebReques t)WebRequest.Cr eate(MSURI);

CredentialCache MSCredentialCac he = new CredentialCache ();

MSCredentialCac he.Add(MSURI, "Negotiate" , MSCred);
MSHttpWebReques t.Credentials = MSCredentialCac he;
MSHttpWebReques t.Method = "PUT";
MSHttpWebReques t.ContentType =
"text/plain";//"applicatio n/x-zip-compressed";
MSHttpWebReques t.Headers.Add(" Translate", "f");
MSHttpWebReques t.Timeout = 30000;
MSHttpWebReques t.KeepAlive = false;

FileStream ostream;
byte[] obuffer;
ostream = File.OpenRead(A ppConfig.XMLFee dFilePath + ZIPFile.Name);
obuffer = new byte[ostream.Length]; // byte buffer
ostream.Read(ob uffer,0,obuffer .Length);
Stream srWriter=null;
srWriter = MSHttpWebReques t.GetRequestStr eam();
srWriter.Write( obuffer,0,obuff er.Length);
srWriter.Close( );
ostream.Close() ;
HttpWebResponse MSResponse =
(HttpWebRespons e)MSHttpWebRequ est.GetResponse ();
MSResponse.Clos e();

Has anyone else experienced similar behaviour and if so how were you
able to solve it.

Aug 31 '06 #1
0 1519

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

Similar topics

5
1341
by: William GS | last post by:
Hello. How can I determine if a folder is shared? if it is shared, how can I retrieve the resource shared name? I have: Folder name ==> C:\WORKS\DOCS Resoure shared name ==> DOCUMENTS With 'WNetOpenEnum()' and 'WNetEnumResource()' I can get '\\MYPC\DOCUMENTS' but there is not relation with real name folder.
0
1388
by: wym | last post by:
I have written a web service that provides the following methods: UploadFile SetNTFSSecurity Their purpose is to allow a user to Upload a file to a shared folder with "Everyone" as permission and using SetNTFSSecurity, allow for tighter security on the files (remove the propagated "Everyone" from parent folder and add specific users to...
7
1452
by: chuckdfoster | last post by:
I am developing an ASP.NET site where an site administrator can upload files via ASP.NET into a Documents folder. These documents are then viewed by site users. I used the MS KB article http://support.microsoft.com/default.aspx?scid=kb;en-us;323245 to learn how to do this. Is there a security issue with this. If you are giving the ASPNET...
2
2063
by: Just Me | last post by:
If I use the shell32q.NameSpace(k) and the Parent property I can develop, for example, the path to My Music. Actually it ends with Desktop but Desktop can also be traced by using Parent to the drive. This desktop is referred as DESKTOPDIRECTORY However, if I try to develop a path to Shared Music I get to Desktop/My Computer.
5
4323
by: Phil Kelly | last post by:
Hi I need to write the contents of a structure to a binary file - there is one string and 2 integers, but I can't seem to figure out how to write the data correctly. If I am simply writing text to a file there is no problem - that starts when I attempt to write the structure. Can someone help me out, please?
1
1655
by: Paul | last post by:
My site does not have a domain name, just an IP address. I set a cookie in ASP.Net and I can read it with no problem on subsequent pages. My problem is that I want to actually see the file on my local workstation (Windows XP) but I can not seem to find it? I have looked in the Temporary Internet Files folder and the Cookies folder for...
2
1472
by: Zoliq | last post by:
Hi, I have a serious problem. I'm currently developing an application in which the user should upload many files (600-700 xml files). I've searched the web for a while and so far I realized that there's no way to use the HtmlInputFile class to achive the desired effect just because I can't set programatically the property of the class that...
3
4218
by: =?Utf-8?B?UGF1bA==?= | last post by:
I need to programatically upload a text file to a web server using the HTTPWebRequest object within .Net 2.0. So far, I have determined that: - I need a HTTP content-type of "multipart/form-data". - I need to use the ContentType.Boundary property. That is about as far as I have gotten.
5
17695
by: =?Utf-8?B?QWRyaWFuTW9ycmlz?= | last post by:
Hello! I'm trying to copy a file from another computer on the network that I do not have permission with my current logon details to access. If I open the folder using the Windows file manager with the path "\\ 192.168.2.2\temp" (where temp is a shared directory on server \\192.168.2.2), windows prompts for a User Name and password of a...
0
7664
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...
0
7583
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...
0
7885
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
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...
0
7948
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...
1
5484
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...
0
5213
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...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1198
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.