[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

how to download a file a from web service in c#or vb.net 2005

Posted on 2007-11-20
4
Medium Priority
?
654 Views
Last Modified: 2010-07-27
I want to create a web service which will check a database for the my application version and if it find any new verson then it will send a file (latest Setup) to the client computer. so that the client can have the latest update.

i want to ask that is it possible that my web serive send the the latest setup file to the client computer.
and if yes then how (some code sample).

and also i want to do this process silently, i means i donot want to show any screen or dialog untill the update is donwloaded on the client pc.
0
Comment
Question by:ziorrinfotech
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 375 total points
ID: 20326002
In the web service you can return the data of the file:

[WebMethod]
public byte[] GetLatestSetup() {
   return System.IO.File.ReadAllBytes(setupFileName);
}

On the client you call the service:

using (service = new TheWebReference()) {
   byte[] data = service.GetLatestSetup();
}
System.IO.WriteAllBytes(localSetupFileName, data);

You might want to add a method to check the version of the settings, so that you don't have to download it every time.
0
 

Author Comment

by:ziorrinfotech
ID: 20332807
GreenGhost

the code which you suggested is working fine if i run this on my local machine and give
 setupFileName = localmachine path (E:\setup.exe)

but when i gave a path other other the local machine then it gives me the error mention below.
i want to download a file which exists on internet server
so i gave this value in setupFileName ="http://xxx.com/update/setup.exe"

then it gave me this error.
pls help me how can i solve this issue

System.Web.Services.Protocols.SoapException was unhandled by user code
  Message="System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.ArgumentException: URI formats are not supported.\n   at System.IO.Path.NormalizePathFast(String path, Boolean fullCheck)\n   at System.IO.Path.GetFullPathInternal(String path)\n   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)\n   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)\n   at System.IO.File.ReadAllBytes(String path)\n   at ClipWebService.GetLatestSetup() in f:\\Deepak\\Personal\\Asp.net2.0\\Practise\\ClipWebService\\App_Code\\ClipWebService.cs:line 30\n   --- End of inner exception stack trace ---"
  Source="System.Web.Services"
  Actor=""
  Lang=""
  Node=""
  Role=""
  StackTrace:
       at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
       at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
       at localhost.ClipWebService.GetLatestSetup() in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\clipwebsite\bfa64d05\baaed92c\App_WebReferences.pebyhuhu.0.cs:line 93
       at _Default.Button2_Click(Object sender, EventArgs e) in f:\Deepak\Personal\Asp.net2.0\Practise\ClipWebSite\Default.aspx.cs:line 29
       at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
       at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)



0
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 20333108
You can't use an URL to open a file. Either use an UNC path (like \\servername\path\to\file\thefile), or send a http request for the file (using the WebClient class for example).

Why don't you just put the web service on the server where the file is?
0
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 20335816
Is there something missing in the solution, or why did you grade it B?

I see that you rarely give A grades, eventhough the solutions given to you seem perfectly fine. If you grade poorly, people will hesitate to help you.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question