Delete a line from a text file

  • (2 Pages)
  • +
  • 1
  • 2

21 Replies - 5958 Views - Last Post: 01 September 2008 - 01:21 PM Rate Topic: -----

#1 Guest_NIXZ*


Reputation:

Delete a line from a text file

Posted 01 September 2008 - 07:43 AM

How can i delete the second line of a text file when this method isnt working?:

			DeleteLine("C:\Text.txt", 2)


Is This A Good Question/Topic? 0

Replies To: Delete a line from a text file

#2 jacobjordan  Icon User is offline

  • class Me : Perfection
  • member icon

Reputation: 115
  • View blog
  • Posts: 1,499
  • Joined: 11-June 08

Re: Delete a line from a text file

Posted 01 September 2008 - 08:22 AM

Well, what is the method??
Was This Post Helpful? 0
  • +
  • -

#3 Guest_NIXZ*


Reputation:

Re: Delete a line from a text file

Posted 01 September 2008 - 09:25 AM

The method is: DeleteLine(C:\MyTextFile.txt, 2) :huh:

This post has been edited by NIXZ: 01 September 2008 - 09:25 AM

Was This Post Helpful? 0

#4 gbertoli3  Icon User is offline

  • DIC at Heart + Code
  • member icon

Reputation: 41
  • View blog
  • Posts: 1,166
  • Joined: 23-June 08

Re: Delete a line from a text file

Posted 01 September 2008 - 09:26 AM

We can't see the code for DeleteLine

It should look something like:
private void DeleteLine(String file, Int32 line)
{
//TODO CODE
}


Was This Post Helpful? 0
  • +
  • -

#5 Guest_NIXZ*


Reputation:

Re: Delete a line from a text file

Posted 01 September 2008 - 09:40 AM

View Postgbertoli3, on 1 Sep, 2008 - 09:26 AM, said:

We can't see the code for DeleteLine

It should look something like:
private void DeleteLine(String file, Int32 line)
{
//TODO CODE
}




:Start
%command%(%file%,%line%)
set command = "DeleteLine" Delete a line from a file (obviously text) same as WriteLine.
set file = "C:\MyTextFile.txt" The File name and path.
set line = "2" Specify the actual line to be erased.

Whats the prob?
Maybe the DeleteLine isnt a command that can be recognized
maybe it needs something like

Dim writer As New StreamWriter("C:\MyTextFile.txt")
writer.DeleteLine("2") or (2)
writer.Close()


Doesnt Work...

Heres the website i found it:
http://www.freevbcod...ode.Asp?ID=2667

Since i ve copied and pasted the code to Microsoft Visual Studio 2008
(after little adjustments to what i need) it doesnt seem to work then
i thought that you guys should help to solve it thats why i created
a new thread. After 15 Views you posted your... :huh: "post" and...
Goto Start

This post has been edited by NIXZ: 01 September 2008 - 09:42 AM

Was This Post Helpful? 0

#6 gbertoli3  Icon User is offline

  • DIC at Heart + Code
  • member icon

Reputation: 41
  • View blog
  • Posts: 1,166
  • Joined: 23-June 08

Re: Delete a line from a text file

Posted 01 September 2008 - 09:42 AM

Use the code tag when posting your code
Posted Image

Quote

writer.DeleteLine("1")


There is not DeleteLine in a StreamWriter

This post has been edited by gbertoli3: 01 September 2008 - 09:49 AM

Was This Post Helpful? 0
  • +
  • -

#7 Guest_NIXZ*


Reputation:

Re: Delete a line from a text file

Posted 01 September 2008 - 09:59 AM

View Postgbertoli3, on 1 Sep, 2008 - 09:42 AM, said:

Use the code tag when posting your code
Posted Image

Quote

writer.DeleteLine("1")


There is not DeleteLine in a StreamWriter


DeleteLine Command by its own doesnt work
Writer.DeleteLine Command Doesnt Work
With What Does DeleteLine has to be for it to work ???
Was This Post Helpful? 0

#8 gbertoli3  Icon User is offline

  • DIC at Heart + Code
  • member icon

Reputation: 41
  • View blog
  • Posts: 1,166
  • Joined: 23-June 08

Re: Delete a line from a text file

Posted 01 September 2008 - 10:05 AM

Can you post the exact code you are using?

Quote

Writer.DeleteLine Command Doesnt Work


That's because the DeleteLine is not in a StreamWriter
There is WriteLine, but not DeleteLine.
Was This Post Helpful? 0
  • +
  • -

#9 Guest_NIXZ*


Reputation:

Re: Delete a line from a text file

Posted 01 September 2008 - 10:26 AM

Am i talking to a script?

Why cant you understand
im using this code to delete a line from a text file
DeleteLine(C:\MyTextFile.txt, 2)
in a code tag:
DeleteLine(C:\MyTextFile.txt, 2)


I use that 35 character (space included) code when i
want to delete the second line (2) from the file
i "Nick ..." named "MyTextFile.txt" located in "C:\"

:crazy:

Can you plz help and tell me what code is the right
one??? please :sleepy:
:stupid:

Posted Image

This post has been edited by NIXZ: 01 September 2008 - 10:29 AM

Was This Post Helpful? 0

#10 gbertoli3  Icon User is offline

  • DIC at Heart + Code
  • member icon

Reputation: 41
  • View blog
  • Posts: 1,166
  • Joined: 23-June 08

Re: Delete a line from a text file

Posted 01 September 2008 - 10:32 AM

I am not some ARS(Automated Response System), I am a human being.

That is not the code I was asking for.
I was asking for the DeleteLine code. Do not give me the code to delete the line. Give me the code that actually deletes the line.

I do not want this
DeleteLine("Dir\Sub\File.txt", 5)



I want
Private Sub DeleteLine(ByVal file As String, ByVal line As Int32)
'TODO CODE
End Sub


This post has been edited by gbertoli3: 01 September 2008 - 10:33 AM

Was This Post Helpful? 0
  • +
  • -

#11 Guest_NIXZ*


Reputation:

Re: Delete a line from a text file

Posted 01 September 2008 - 10:42 AM

OK
I Dont Use/Dont Know the 'TODO CODE
JUST THE: DeleteLine(imbored.txt, 5) itself
no Pivate Sub ...e = mc2 unified theory
stuff before that just that code

What Code do you use to delete a line from
a file plz post that before posting anything else.

This post has been edited by NIXZ: 01 September 2008 - 10:43 AM

Was This Post Helpful? 0

#12 gbertoli3  Icon User is offline

  • DIC at Heart + Code
  • member icon

Reputation: 41
  • View blog
  • Posts: 1,166
  • Joined: 23-June 08

Re: Delete a line from a text file

Posted 01 September 2008 - 10:46 AM

Are you saying that there is not Private / Public Sub called DeleteLine?
Was This Post Helpful? 0
  • +
  • -

#13 Guest_NIXZ*


Reputation:

Re: Delete a line from a text file

Posted 01 September 2008 - 10:52 AM

View Postgbertoli3, on 1 Sep, 2008 - 10:46 AM, said:

Are you saying that there is not Private / Public Sub called DeleteLine?


Nup :lol:
Was This Post Helpful? 0

#14 gbertoli3  Icon User is offline

  • DIC at Heart + Code
  • member icon

Reputation: 41
  • View blog
  • Posts: 1,166
  • Joined: 23-June 08

Re: Delete a line from a text file

Posted 01 September 2008 - 10:53 AM

Nup?

Is that a No? Yes?
Was This Post Helpful? 0
  • +
  • -

#15 Guest_NIXZ*


Reputation:

Re: Delete a line from a text file

Posted 01 September 2008 - 10:58 AM

View Postgbertoli3, on 1 Sep, 2008 - 10:53 AM, said:

Nup?

Is that a No? Yes?


Thats No
Was This Post Helpful? 0

  • (2 Pages)
  • +
  • 1
  • 2