c# - How to process multiple files fetched using openFileDialog using Streamreader class? -


How do I read two files that I have faded from the openFileDialog box? Below is the code that I have written. Private Zero LoadBetBetton_click (Object Sender, EventErgus E) {var OpenFileDialog = New OpenFileDialog (); OpenFileDialog.Multiselect = True; XmlSerializer serializer = New XmlSerializer (type (list & lt; ExtractSerializedAction & gt;)); StreamRedder myReader = Faucet; Foreign (openFileDialog.FileNames in string file) {myReader = new streamrider (file); } Var Results = Serializer. As a list of diaryials (& lt; ExtractSerializedAction & gt;; myReader.Close (); Forchach (different items in result) {// some code here}; }

The above code only brings the previous file that I select using openFileDialog . I know that the problem is with streamreader logic and foreach loop but do not know how to solve it?

Try this:

  string (file in the openfileDialog.FileNames } {{StreamReader myReader = new StreamReader (file)) is used as a {var result = serializer.Deserialize (myReader) list & lt; ExtractSerializedAction & gt;; Foreach (results in var items) {// some code here}}}   

Note: You declared the stream reader object inside the block to myReader As if my code is so that you can remove the StreamReader object declaration (the following statement) out of the loop.

  StreamReader myReader = null; // Remove it    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -