C# - How To Detect Duration A WebClient.DownloadData() Takes To Complete
Nov 22, 2010how can i tell how long a:objWebClient.DownloadData(strURL)
takes to complete?i wish there was a property that contained this info but i couldn't find one...
how can i tell how long a:objWebClient.DownloadData(strURL)
takes to complete?i wish there was a property that contained this info but i couldn't find one...
I'm using a third party url to determine the location of site visitors based on IP address.I use WebClient.DownloadData() to get the information returned by the url which is a one word answer e.g. as per http://api.hostip.info/country.phpOnce I have detected what country the user is in I want to either A) keep them on the current site and store the country in the session or B) redirect them to another countries site.What I'm worried about is WebClient.DownloadData() hanging so the user is waiting for ages and can't use the site. I'd thought about using DownloadDataAsync but this dosn't seem to be a solution for me as I don't want them to do anything till I find out the country (also seettp://stackoverflow.com/questions/271767/webclient-downloaddataasync-is-freezing-my-ui)Is there a way I can set a timelimit on my call to WebClient.DOwnloadData e.g. if it hasn't returned in 2 seconds,
View 1 ReplieswebClient.postme
Can't get WebClient.DownloadData() to work
My question is similar to http://stackoverflow.com/questions/194579/how-to-detect-when-a-user-has-successfully-finished-downloading-a-file-in-php but I have to do the same using IIS, ASP.NET and C#.
None of the methods in the HttpResponse class provide feedback if the data was sent or not, TransmitFile just does its job (or not) and does not provide any means of knowing the result.I was thinking of using the .Filter property but then again, the filter is based on the HttpResponseStream which does also not provide any feedback.
I'm mix up between webclient.OpenReadAsync and webclient.DownloadStringAsync? Can anyone explain clearly for me ? What are the difference between them? In addition, may i know whether webclient.OpenReadAsync got download the file or just open and read the file only without download to other places?
View 3 RepliesI run a loop that downloads a lot of smal files from another website
try
Loopstarts
result = runData()
loop ends
catch ex1 as exception
End try
private function runData() as string
Dim wc as new WebClient
Dim str as string
try
str = wc.downloadstring(filePath)
catch ex2 as exception
return "Nothing"
end try
wc.dispose()
finally
return str
end function
THE Problem is if the file is not found in the RunData function I get 'Thread being aborted' error which stops the not only the function RunData() but also the loop is running in, so I get an error in ex2 as well as ex1. But I want the error to be captured in ex1 and stop, and not effect the loop.
I have read that you need to use Response.End to close the thread or not to capture the 'threadbeingaborted' expception.
BUT how do you do the response.end with a webclient??? (IN vb.net , asp.net 2.0 version
I am deciding to output cache my page and i need to set duration as never expiring. how can i achieve this? Also if i do not specify any location, where will the cache get stored? client or server? Ram or hard disk ?
View 4 RepliesI am currently using C# and the webClient class to downloading and uploading images, data, see code below
[code]....
This works fine for a direct internet connection, but fails through a proxy server.
And giving the error "The remote server returned an error: (407) Proxy Authentication Required."
I have tried using the default credentials in the credentials property
[code]....
Is there any method for finding the duration of an uploaded video without running any exe (ffmpeg.exe) in asp.net?
View 1 RepliesI've tried using directshowlib-2005 by installing k-lite mega codec pack. It can't find the duration of an mp4 file or f4v file (avi, wmv and flv has no problem). I use ImediaSeeking interface of directshowlib-2005 to find duration. But in case of mp4 and f4v the GetDuration method returns zero.
I know it is a codec problem, but I do not know which codec is to be installed to get duration of mp4 as well as f4v files.
The code I am using is shown below:
[Code]....
I am downloading a file from remote server by using the following code.
[code]....
If we paste the remote url in browser then it is downloadding the file without any error/warning.
I have an load of images on my form with the purpose that if the user holds the mouse on it, (s)he gets a tooltip with some information. The image is a questionmark.The users are now asking if the duration of this tooltip can be extended so they actually can read all of the tekst.So it would be great if a TooltipExtender could be created that can be connected to a image control (or any other)
View 2 RepliesIt seems that webclient supports PUT and POST uploading. Is there any difference?
View 1 Repliesin my application i want to display the duration time of the video ( that is time of the video) in asp.net
View 2 RepliesI've got a site that users can use to check in and out documents. To check out a document, the user slects a file from a list, and clicks 'check out' . The document is taken from a 3rd party source control tool and placed in a dedicated directory on the server. Then, the file needs to be copied from this directory to a client directory the user has specified.
Copying to the Server is no problem.
I'm trying to use the WebClient objects DownloadFile method to write to the clients directory, but I keep getting "Access to the path '<path>' is denied.". I've set the UseDefaultCredentials flag to true, but no joy.
I'm obviously missing something, but I'm not sure what.
Anyone familiar with the webclient.downloadfile method method? I'm looking for a way to help two users download files from an internal secure website. Right clicking File Save As, and then browsing to a folder is "too many steps". So, I'm curious what this method can do to reduce clicks and/or automate the download process.
View 7 RepliesI'm using WebClient.DownloadString("http://www.website.com/Default.aspx?fltdte=01050402);Part of data that is returned I want to put again in above url for query again and again if data returned satisfy conditions..I want to do multiple webClient.DownloadString.How to do that?
View 2 RepliesTrying to do basic webclient data pull in C#, and the methods are not available in visualstudio, and the code is not compiling.
//snip
WebClient client = new WebClient();
byte[] resp = client.DownloadData(url);
//snip
Error 1 'System.Net.WebClient' does not contain a definition for 'DownloadData' and no extension method 'DownloadData' accepting a first argument of type 'System.Net.WebClient' could be found (are you missing a using directive or an assembly reference?) C:UsersMichaelDocumentsVisual Studio 2008Projectssearch2search2MainPage.xaml.cs'm doing this in a c# file for a XAML/Silverlight project, but can't imagine why that would make a difference. I can not find any reference to this issue on the web, and I had something similar to this working last month, but in a regular ASP.NET page, not in a Silverlight app.
I have an objective to transfer some files which can be pdf, jpg and xml from one location to another. I am creating a handler based API for that. What could be the best approach for doing it? Should i return a byte array so that the client can pick the byte array and convert it back to file? Also the max file size I need to handle is 18 MB, so i have to make sure that the sizes are properly handled. Should I do an asynchronous transfer for that?
View 1 RepliesNot sure if any of you are familiar with hMailServer, however, I am attempting to automate account creation / editing / deletion by using the WebClient class to interact with hMailServer's PHPWebAdmin.
The problem I am facing is that I can't seem to retrieve the index page (http://localhost/hmailserver/index.php) after posting the login credentials.
Here's my code so far....
[Code]....
And here's the HTML for the login form...
[Code]....
what I'm missing / potential problems? Should the 'url' be the page with the form of which I wish to post data to, or the page I want returned? I've tried setting it to "....hmailserver/index.php" or to the status page ...hmailserver/index.php?page=status" but the response returned is always the HTML of the login page.
created a project in c3.net of online exam wan to set time duration on server side
View 1 RepliesMy asp.net(c#) method looks as follows:
[Code]....
I got the duration with the above method. But my problem is i can't delete the physical file
after my operation. I used
File.Delete(FilePath);
While performing this action i got an exception as follows:
"The process cannot access the file because it is being used by another process."
My Os is windows 7(IIS 7)
I have a web site where i can upload videos. Here i have a requirement that while uploading i should validate that user should not upload video with more than 1 minute duration.
So i doubts how we can implement this validation.
I am using the code below to download multiple attachments from a TFS server:
[code]....
However, there are a couple of problems with this approach:
The Thread.Sleep() is locking up my Form. I still need to make my own Thread or use BackgroundWorker. (I would like to avoid this as much as possible)The DownloadFileCompleted event is being triggered after ALL files has been downloaded. I don't know if this is a side-effect of using
System.Threading.Thread.Sleep(1000);
Is there a better approach to download files one at a time using WebClient.DownloadFileAsync?
I am using MSACCESS as back end.And as we can get database back up in the SQL server after particular time.I want that kind of back up in MS ACCESS.How can i get it..
View 5 Replies