DR00ME Posted March 22, 2004 Posted March 22, 2004 (edited) I got some items in my listbox: 1.222 323 323 555 222 2.124 3.12 12 244 324 54 367 244 0.232 0.212 I want to write them just like that in a file, how do I do it ? and How do I read from a specific row in a file....... ? the main thing I want to know is how to write in a specific row in a file.... yeah...using filestream not fileopen or whatever it was...I know this takes a bit of your time but if you got some old example I would be more than grateful... Edited March 23, 2004 by DR00ME Quote "Everything should be made as simple as possible, but not simpler." "It's not that I'm so smart , it's just that I stay with problems longer ." - Albert Einstein
Leaders Iceplug Posted March 22, 2004 Leaders Posted March 22, 2004 File I/O using a Stream is sequential... unless you know the exact location of the line in the file that you want to read from, you will have to read each line one by one until a counter that you make reaches the value that you want to look at. :) For writing the contents of a listbox to file, it would seem that you'd only have to use a For Loop on the ListBox.Items and use your Stream's .WriteLine property to write that entry in the listbox to file. :) Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
DR00ME Posted March 23, 2004 Author Posted March 23, 2004 So, how do I write in separate rows, any samples ? :) Quote "Everything should be made as simple as possible, but not simpler." "It's not that I'm so smart , it's just that I stay with problems longer ." - Albert Einstein
Leaders Iceplug Posted March 23, 2004 Leaders Posted March 23, 2004 You use the .WriteLine of your file stream in a For Loop. Is that too complex? What did you do based on what I mentioned? For LV = 0 To LBx.Items.Count - 1 SW.WriteLine(LBx.Items(LV)) Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
DR00ME Posted March 23, 2004 Author Posted March 23, 2004 (edited) blah, I'll try to play around with it.... this is what I got so far... [Vb] Private Sub btnCalibrate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalibrate.Click Dim CalibFile As FileStream Dim i As Integer Dim byteArray() As Byte Dim dataString As String Dim fileDataString As String Dim FileHandle As File Dim SR As StreamReader Dim SW As StreamWriter If lstHSL2.Items.Count > 0 Then For i = 0 To lstHSL2.Items.Count() - 1 If dataString = Nothing Then dataString = lstHSL2.Items(i) Else dataString = dataString + ";" + lstHSL2.Items(i) End If Next i SR = FileHandle.OpenText("Calibration.ini") fileDataString = SR.ReadToEnd SR.Close() byteArray = Encoding.Unicode.GetBytes(fileDataString + dataString) CalibFile = New FileStream("Calibration.ini", FileMode.Create) CalibFile.Write(byteArray, 0, byteArray.Length) CalibFile.Close() CalibFile = Nothing End If End Sub[/code] Edited March 23, 2004 by DR00ME Quote "Everything should be made as simple as possible, but not simpler." "It's not that I'm so smart , it's just that I stay with problems longer ." - Albert Einstein
DR00ME Posted March 24, 2004 Author Posted March 24, 2004 yadda yadda everything works now.... Quote "Everything should be made as simple as possible, but not simpler." "It's not that I'm so smart , it's just that I stay with problems longer ." - Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.