4 Replies - 5224 Views - Last Post: 25 July 2010 - 11:57 PM Rate Topic: -----

#1 quitac  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 48
  • Joined: 28-March 09

writing listview items to a txt file

Posted 22 July 2010 - 03:29 AM

hi my frined. I have a program. There is a listview box and in that lsit view there are some info like;


ID | date | hour
----------------------------------------------------
30158 | 20.07.2010 | 20:52:18
30196 | 21.07.2010 | 12:17:17
.
.
.
.
.
.


goes like this.


I want to write all this this data to a txt file like this

1st line = "30158","20072010","205218"
2nd line = "30196","21072010","121717"


but in the txt file there wont write 1st line 2line ect.. But " will remain. How can I do this?

Is This A Good Question/Topic? 0
  • +

Replies To: writing listview items to a txt file

#2 Jack Eagles1  Icon User is offline

  • Pugnacious Penguin (inspired by no2pencil)
  • member icon

Reputation: 183
  • View blog
  • Posts: 1,152
  • Joined: 10-December 08

Re: writing listview items to a txt file

Posted 22 July 2010 - 03:45 AM

I'd suggest creating a string array with each of your rows and coloumn's data in it, and then save that to a text file usinga streamwriter.

Otherwise, you might be able to use Environment.NewLine
Was This Post Helpful? 0
  • +
  • -

#3 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: writing listview items to a txt file

Posted 22 July 2010 - 09:41 AM

To convert the string from the original format to the new format. Once you read in the line and store it (in this example, stored to a string named String1) you can do the following to replace and insert characters.

        string1 = string1.Replace(" | ", """,""").Replace(".", "").Replace(":", "").Insert(0, """") & """"


Then save the newly formed string back to a file

This post has been edited by CharlieMay: 22 July 2010 - 09:42 AM

Was This Post Helpful? 1
  • +
  • -

#4 Frinavale  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 203
  • View blog
  • Posts: 776
  • Joined: 03-June 10

Re: writing listview items to a txt file

Posted 23 July 2010 - 07:41 AM

Before you can do either of the two suggestions already made you need understand that you have to do this while loopings through the ListView's items.

(Pseudo code)

For each item in the ListView,

Create a string that will contain the item's data

For each sub-item within the item

Add the value to the string

Loop...

Add an newline to the end of the string and then add the string to the text file

Loop...


-Frinny

This post has been edited by Frinavale: 23 July 2010 - 07:43 AM

Was This Post Helpful? 0
  • +
  • -

#5 quitac  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 48
  • Joined: 28-March 09

Re: writing listview items to a txt file

Posted 25 July 2010 - 11:57 PM

@charlieMay thank you. It works.

also thanks all of you friends, for allocating your time.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1