473,549 Members | 2,726 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem in code for downloading files from web server.VIP

(Type your message here)

--------------------------------
From: Amol Guttal
Hi,
This is the code which used to download a file from webserver.
If I point a file in my localhost for download it is working fine but when I point to a file in a remote server it is downloading the file but is corrupted and can't be open.
Please reply back soooooon.

Response.Clear( );
Response.ClearC ontent();
Stream remoteStream = null;

WebResponse response = null;
string file = "http://www.xyz.com/n.ppt";or //localhost/scripts/n.ppt.
WebRequest request = WebRequest.Crea te(file);
if (request != null)
{
// Send the request to the server and retrieve the
// WebResponse object
response = request.GetResp onse();
if (response != null)
{
// Once the WebResponse object has been retrieved,
// get the stream object associated with the response's data
remoteStream = response.GetRes ponseStream();

byte[] Buffer = new byte[response.Conten tLength];
remoteStream.Re ad (Buffer, 0, Buffer.Length);
string extension = System.IO.Path. GetExtension(fi le);
if(extension.St artsWith("."))
extension = extension.Subst ring(1); Response.Conten tType="applicat ion/"+extension ;
Response.AddHea der( "content-disposition","i nline; filename=n.ppt" );
Response.Binary Write(Buffer);
}
}

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>tEwBVAYN4ku F1MaR4odcGQ==</Id>
Nov 18 '05 #1
0 1159

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

Similar topics

1
1565
by: Kajol | last post by:
Hi I am facing a strange problem in downloading files from the web. CASE 1: I have an ActiveX.dll file developed using Visual Basic 6.0 and uploaded on a Linux Server. I am typing http://somedomain.com/somefolder/filename.dll] into the addressbar of the IE, IE is allowing me to download that file with a save dialog box, this is working...
4
2144
by: Himanshu | last post by:
hi, Can anybody tell me that thru asp.net using c#, how can we upload and download physical files in any table of SQL Server Database. the uploading part is running successfully but the problem arises in the retriving part of the code. i am not getting that how will i able to download the file which is there in the SQL Server database in...
2
2421
by: Bala | last post by:
Hi I am trying to download the PDF files from my webserver using ASP.Net. All my files are stored at F Drive on webserver. Like this F:\Main Folder\Sub Folder\Files\File1.pdf I am impersonating the domain user account and downloading the file, It seems the impersonate is got success, but its not download the file. Its simply...
1
2055
by: just.starting | last post by:
Hi, My dot net client downloads files and checks for any new files time to time. The server is apache2.0.53 server. So what happens is that my file download thing works fine if I dont try to call any page from the server while downloading. If I try to call a single page while downloading a file then the page request goes time out and the...
3
2779
by: just.starting | last post by:
Hi, My dot net client downloads files and checks for any new files time to time. The server is apache2.0.53 server. So what happens is that my file download thing works fine if I dont try to call any page from the server while downloading. If I try to call a single page while downloading a file then the page request goes time out and the...
0
1623
by: just.starting | last post by:
I am having problem while downloading files from an apache server2.0.53 with php4.3.10.While downloading some files it generally stops after downloading some specific amount and then stops downloading with the error message: "the source file could not be read". And the error is not dependent on the size of the file, as I can download a file of...
102
6714
by: hug | last post by:
www.webmaster, was suggested that this ng could be a better place.] I've updated my test server to handle if-modified-since. I've noticed that the (old copies I run of) IE and Netscape seem never to send if-modified-since. But the strange thing is that Opera sends if-modified-since but when I reply with "HTTP/1.0 304 Not Modified" it is...
15
4130
by: =?ISO-8859-1?Q?J=F8rn?= Dahl-Stamnes | last post by:
Hello folks, I need some help/advice FAST. I have problems with addslashes on my web-servers. After uploading a file, I read the uploaded file, use addslashes on the read data and then insert it into a blob field in a MySQL database. The problem is that this works fine on my internal test web-server (running under RedHat 7.3). But on...
6
3752
by: cyusman | last post by:
Hi, We have just moved our application to a new webfarm server environment which utilizing hardware load balancing, SSL off-loading and HTTP compression off-loading.My application is running on .NET 1.1, IIS 6, Win2003. Now we are having problem when trying to download word documents located in the file server. It often says Internet...
8
8905
by: Chizl | last post by:
I'm building a web server and having some issues with the TCPListener.Start(BackLog). It doesn't seem to do as expected. I'm using MS Web Stress Tool to test against my web server and when I see 200 connections at once to it, and I'm seeing 2/3 of the sockets as socket errors.. They never get into my code, so it has to be failing on the...
0
7524
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
7451
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
7720
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
7960
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
6048
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5089
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
3501
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...
1
1944
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1061
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.