How to retrieve parameters from a text file
Hello, I want to create a windows console program that receives as parameter as input a text file which I have set in the translate format, which must contain 5 values, I read the file, and be able to recover the 5 values and then insert them into my database I do not know how do I define the format of for my file, if you have an idea,please suggest me this is because i am trying this since very long time.
Thanks in Advance
Re: How to retrieve parameters from a text file
Hi!
If really need to retrieve the parameters from the text file with the 5 values you should be aware that this value corresponds to what or what is important and once you have been recovered, you insert them in your base "randomly"?
If you must know that such a value corresponds to chose you can make a couple of species <Key/Value> or <Key=Value>, etc.. with a pair per line.
Re: How to retrieve parameters from a text file
Thanks, i was eager to know about this, you have really provided me the key value, i understood that I need to create a method in which I have to give the file path, it will read the file and then retrieves the value and insert them into the database, if i am mistaking somewhere then please explain me with the example. * I'm interested!
Re: How to retrieve parameters from a text file
Hi,
If you have gone through the some blogs or forums reading then you can play with StreamReader and function Split () on strings but before going through this you must have some knowledge about it about how to read & retrieve the key and the value of a line.
I will explain with the little informative, StreamReader constructor takes a file to read it as a parameter and you can then read (using the Read () or ReadLine ()) your StreamReader until it return null.
Re: How to retrieve parameters from a text file
The idea of a method to return the result is a good idea but thought that it must return, how you want to use it then.
And if you give a file to be read as a parameter to this method, you arrange for the method takes a string as a parameter (not a StreamReader).In short, you have perhaps been a little fast but they are small details of inattention.