Webclient upload file silverlight
Net namespace. This article is the continuation of my last article in Silverlight controls series, read last article here. NET Online training here. On click of the Button, we shall write our code to download the file.
Once the download is complete, we should show the success message in TextBlock1. The content of the file downloaded is shown in the TextBlock3 that is in tern into ScrollViewer control.
RelativeOrAbsolute ;. OpenReadAsync uri ;. ReadToEnd ;. In this method, we have instantiated the WebClient class. We have also specified a file to download; in this case we are trying to download a RSS feed data. We can also download any local file from server provided that is inside the ClientBin folder.
At last we have called OpenReadAsync method by passing the uri to download that basically starts downloading the file asynchronously. This method fires when the file download starts. This method fires when the file download is complete. In this method we have first checked for error, if it is not we are getting the result of the download and reading to the stream and setting TextBlock3 text to the content of downloaded file. If there is an error, we are writing error.
Skip to main content. This browser is no longer supported. Download Microsoft Edge More info. Contents Exit focus mode.
Web Client. Upload File Method Reference Is this page helpful? Please rate your experience Yes No. Any additional feedback? Namespace: System. Net Assembly: System. Uploads a local file to a resource with the specified URI. On the button click event handler, I write code to call the OpenFileDialog that allows us to browse files and gives us the selected file name. Here is the code. ShowDialog ; if retval!
Name, dlg. OpenRead ; StatusText. The UploadFile method looks like the following. Result ; e. Close ; data. OpenWriteAsync ub. We don't think you can do it as your above description. Wednesday, March 11, AM. Use OpenFileDialog Box. Thanks for your reply. Any Example code please I am not trying to open any file rather i want to upload in to my project You can add files to your project by right-clicking the project and selecting "Add Existing Item.
I want to make this through silverlight programming, not manually So, you'd like to browse the contents of someone's computer, without asking them, rummage through it, and take files off their hard drive? You can't do that in Silverlight -- for some reason. Might you understand differently i think. Please go through my requirement clearly once again. Let us say my project is in drive c: Ex. In front end i have a fileupload control, where i can click browse then this file has to add to my project folder Waiting for a better reply.
Thanks in Advance I completely understand you. Silverlight does not allow you to browse the hard drive, and it especially does not allow you to create a duplicate of a file.
0コメント