Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (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 by DR00ME

"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
Posted

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. :)

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Posted
So, how do I write in separate rows, any samples ? :)

"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
Posted

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))

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Posted (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 by DR00ME

"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

Posted
yadda yadda everything works now....

"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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...