Hi,
I am using this code to download files on VS 2005. It downloads the file but
waits until the timeout (which is why it is so short) to add the last 4
bytes or so. It always returns a WebException which most of the time is just
feedback from the FTP server, so how do I tell if the download was
successful/complete or not?
Tim
public void DownloadFile(st ring fileName, string mfgrId)
{
try
{
string destinationFile = @"C:\Program Files\MM\" + fileName;
FileInfo file = new FileInfo(destin ationFile);
FileStream localfileStream ;
FtpWebRequest request = WebRequest.Crea te("ftp://" + hostname + downloadDir
+ fileName) as FtpWebRequest;
request.Method = WebRequestMetho ds.Ftp.Download File;
request.Timeout = 5000; //five seconds
if (file.Exists)
{
request.Content Offset = file.Length;
localfileStream = new FileStream(dest inationFile, FileMode.Append ,
FileAccess.Writ e);
}
else
{
localfileStream = new FileStream(dest inationFile, FileMode.Create ,
FileAccess.Writ e);
}
WebResponse response = request.GetResp onse();
Stream responseStream = response.GetRes ponseStream();
byte[] buffer = new byte[1024];
int bytesRead = responseStream. Read(buffer, 0, 1024);
while (bytesRead != 0)
{
localfileStream .Write(buffer, 0, bytesRead);
bytesRead = responseStream. Read(buffer, 0, 1024);
}
localfileStream .Close();
responseStream. Close();
ErrorReporter.L ogableError(fil eName + " downloaded successfully",
ErrorReporter.E rrorTypes.DDS);
}
finally
{
}
} 0 1636 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: singh_chintu |
last post by:
I have uploaded a file that is over 8MB and that is successful and I
have verified that it is a successful upload.
However, that same file seems to have a download limitation of 2MB
which I thought only applied to uploads. When downloading via IE, it
shows the actual file size of 8+MB but then stops quarter of the way at
2MB.
Is this a simple configuration fix that I am missing?
|
by: Brent Billups |
last post by:
I am trying to download files from one website to another for purposes
of caching. In trying to do this, I created a VB dll component (using
VB6), that used URLDownloadToFile, to allow me to download the file
onto the receiving site. The sending site supports an ASP page that
allows the file to be downloaded.
The component works fine when run in debugging mode, placing the file
as expected. But when not debugging (but registered), it...
|
by: Chuck Anderson |
last post by:
I am writing a Php script to run on my home PC (Windows) that downloads
an Apache access log file and inserts new entries into a database.. The
only way I can access these log files is through a cPanel URL that
delivers a gzipped copy of the log file with all entires for the current
month (up to the current date and time).
I want to run this script once a day (at night) and would like to
download the gzipped file by resuming from where...
|
by: Tom |
last post by:
Hi,
I have a website providing pdf file downloading for registered member.
Member needs to login and be able to download pdf file.
I save pdf file in a directory. e.g. http://www.downloadpdf.com/pdf/abc.pdf
However, I needs to restrict those non-member to download the pdf file
directly by input the URL http://www.downloadpdf.com/pdf/abc.pdf.
|
by: Hitesh |
last post by:
Hi,
I am having a requirement where in user can click on a link and the download
popup appears and then user should be redirected to a congratulations page.
We didn't bother whether the download is successful or not but as soon as
user clicks on the download link the popup appears, and then the user should
be directed to the congratulations page.
I have written the standard code to download the file but after that i am
| |
by: sc48567189 |
last post by:
Hello ! I need some help here. I google after the response but with no
sucess.
I need to download - randon size - parts of a file, not the whole file.
Says: I have the zip file test.zip, it is 10 mega bytes long. But I
don't want the 10 mega today. Today I want 5 mega bytes. Tomorrow I
could want more 3 mega bytes of the file, but it is not sure, could be
4 mega bytes. I need to part the zip file in chunks at request. No CGI,
no asp, no...
|
by: bonita |
last post by:
If I add the code for user to download the file (e.g.
if(File.Exists(FILE_NAME)){......}), the ASP.NET will give the
following timeout error:
Timeout expired. The timeout period elapsed prior to completion of the
operation or the server is not responding.
It seems that the download file code is executing before letting the
previous code to finish. Even the message print code
(message.Text="...";) is not executed.
|
by: a.r.austin |
last post by:
Hello,
I am trying to download a few files one after another from a remote
server. Problem is that I don't know how to, or if I am able at all,
set a time out for download. I don't want to time out whole script,
just a part if file won't download in 2mins then skip to the next one.
Previously, I had a Javascript implementation with AJAX, this time I
thought of doing it in PHP since PHP has far better array functions, I
don't have to do...
|
by: Tushman |
last post by:
I'm a first time poster and know very little about programming.
My situation is that I found a website (ImageFap) that has picture thumbnails. Of course in order to view them, you have to click on each individual one. The only problem is that because the site uses a PhP script, I cannot use the download manager I have to get all the photos. There's tons of pics on the site and I could spend 4-5 hours clicking on each pic. Is there some way to...
|
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,...
|
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...
| |
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...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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();...
|
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...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |