NET, covering C 6. NET Core, with chapters on the latest. NET Core 3. NET Standard and C 8. Use these concepts to deepen your existing knowledge of C and. NET, to have a solid grasp of the latest in C and. NET OR to crack your next. NET Interview. Silverlight 4. Views: Abstract: This article demonstrates how to upload multiple files to the server using Silverlight 4. Let us assume a business requirement as below: The end-user is using a Silverlight application.
The code is as shown below: The method ProcessRequest accepts the input file to be written on the disk as a QueryString. The code is as shown below: Step 6: In the code-behind, write a method which will write the uploaded stream in to the target stream.
The entire source code of this article can be downloaded over here This article has been editorially reviewed by Suprotim Agarwal. Was this article worth reading? Share it with fellow developers too. Follow him on twitter maheshdotnet or connect with him on LinkedIn.
Feedback - Leave us some adulation, criticism and everything in between! Its awesome. You will see your default Page. Step 2 On Create Page. 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. In code block you can see that we are creating array of bytes with size as that is the default maximum size of the file that can be uploaded. In case you want to allow bigger file, change the bytes array size.
At last we are calling OpenWriteAsync method by passing the uri of the generic handler. This method calls the generic handler because of Uri into OpenWriteAync method. Now create a generic hanlder UploadFile. Below is the code for my generic handler.
QueryString[ "file" ];. In the above code snippet, we are first retrieving the file name being passed from the querystring. Next we are using FileStream to create a file based on the file name being passed here note that we are also passing the folder name — UserData where our files gets uploaded, we must have write permission to this folder.
Keep an eye on forth coming articles on Silverlight. To read my series of articles, click here. Comments or Responses. Login to post response. How to download and upload a file to the server in silverlight? Get ASP. Networking Silverlight also allows us connect to remote machine or services, download and upload files, all these stuffs are done using WebClient class that exists into System.
How to download file and displaying progress status? Thanks for noting, I wasn't aware of UploadFileAsync. I've done a little searching and came across that it wasn't supported in SL I'll look into if it's supported in version 3 and update the code accordingly. You are right, it seems like it is not, not even in 3.
I tried uploading a doc and a ppt, but after uploading it, I cannot open it in powerpoint, it gives me an error "The presentation cannot be opened. Did any one else find the same error? Show 1 more comment. Zorayr Zorayr Mamoon ur Rasheed Mamoon ur Rasheed 3 3 silver badges 14 14 bronze badges. The Overflow Blog.
0コメント