473,799 Members | 2,746 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to replace single line in text withot saving the file?

11 New Member
I need to open some HTML file, then replace exact line of text with another, and then WITHOUT SAVING THE FILE (WriteAllLines( HTML01, lines)) to display in WebBrowser. My code in private sub of replacing the line is next:

Expand|Select|Wrap|Line Numbers
  1.         Dim lines() As String = System.IO.File.ReadAllLines(HTML01)
  2.         lines(7) = "editovan HTML"
  3.         WriteAllLines(HTML01, lines)   'without this line, just in RAM memory
  4.         WebBrowser1.DocumentText = System.IO.File.ReadAllText(HTML01)
  5.  
The file "HTML01" as already opened.

Thanks in advance!
Jul 23 '11 #1
1 2065
Marko Danilovic
11 New Member
In the meantime I resolve the question by myself:

Expand|Select|Wrap|Line Numbers
  1. Imports System.IO.File
  2. Imports System.IO
  3. Imports System.Text
  4.  
  5. Public Class Form1
  6.  
  7.     Dim HTML01 As String = (CurDir() & "\10.html")
  8.     Dim HTML02 As String
  9.  
  10.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  11.         WebBrowser1.DocumentText = System.IO.File.ReadAllText(HTML01)
  12.     End Sub
  13.  
  14.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  15.  
  16.         Dim lines() As String = System.IO.File.ReadAllLines(HTML01)
  17.         lines(7) = "edited HTML"
  18.  
  19.         Dim HTML02 As String = ""
  20.         For i = 0 To 8 ' lines in HTML01 is 9
  21.             If i = 8 Then
  22.                 HTML02 = HTML02 & lines(i)
  23.             Else
  24.                 HTML02 = HTML02 & lines(i) & Chr(13) & Chr(10)
  25.             End If
  26.             'MsgBox("linija:" & i & " = " & lines(i))
  27.         Next i
  28.  
  29.         'System.IO.File.WriteAllText(putanja, HTML02) - this line is no need it
  30.         WebBrowser1.DocumentText = HTML02
  31.  
  32.     End Sub
  33. End Class
  34.  
Oct 22 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

18
21936
by: William Payne | last post by:
Hello, I need to write a program that opens a text file and scans the entire file for a specific line and when that line is found, a particular word on that line is to be replaced. The new word is given as an argument to the program. I wrote a small test program that doesn't work because strcmp() fails to find a matching line. Here's the code: #include <stdio.h> #include <string.h> int main(int argc, char** argv)
2
1530
by: Kay L. | last post by:
Hi, when I draw a long text inside a rect, it will go outside, I want to know which charactor is the last one which is inside the rect. I know I can do like below, but it's not efficient, is there any better way to do this, thanks. CString str = "a long text"; // if it's too long, I want to draw "a long t..."; CRect rc(0,0,100,100); char c; for(int i=0; i<str.GetLength(); i++)
4
1482
by: Daves | last post by:
I am saving to database a result from multi-line textbox. The database of course wants \x escape codes, not the invisible ones. Is there any easy - one line code - way to do this (c#) eg by String.Format() ?
7
6555
by: bclegg | last post by:
Hi, I have a Monitoring application that needs to output single line summaries to a local dot matrix printer loaded with line flow. ie. It will have exclusive use of the printer which is connected to LPT1. I need to get the normal number of lines to each page. ie 60 summaries onto a 66 line lineflow page Am I restricted to the Printdocument object and graphics printing or is there a way to do a single line text print?
2
4851
by: Clodoaldo Pinto Neto | last post by:
Hi all, I'm trying to copy a table with a text field column containing a new line char to a file: ksDesenv=# create table page(line text) without oids; CREATE TABLE ksDesenv=# insert into page (line) values('1stline'||chr(10)||'2ndline'); INSERT 0 1
3
2491
by: saad82 | last post by:
I want to be able to replace a single line in a large text file (several hundred MB). Using the cookbook's method (below) works but I think the replace fxn chokes on such a large chunk of text. For now, I simply want to replace the 1st line (CSV header) in the file but I'd also like to know a more general solution for any line in the file. There's got a be quick and dirty (and cheap) way to do this... any help? Cookbook's method:...
2
9892
by: garyusenet | last post by:
I have a multi line text box, i'd like to store the contents of this textbox to a text file. However when I write the value of ' textbox.text ' to the file it is written verbatim spanning many lines if enter has been pressed. I'd like to store the value of the textbox on one single line in the file. How do i do this? I assume i'll need to read new line characters from the textbox.text string, and replace them with some token ?
2
1311
by: shihab | last post by:
I have created two text boxes,One is single line text box other is multiline. On button click i want to 'add text from single text box to Multiline text box'one by one. please give solution for this . thank shihab.
11
3359
by: waffle.horn | last post by:
Hi, if this makes sense i want to create a function that can be called so that it reads a single line from a file, then after using the information destroys it. Such that when the function is called that line of info does not exist anymore in the file. for example i have created a short example of where i am at, but I dont know how to alter what im doing so that i just read in a single line
23
13532
by: dkirkdrei | last post by:
I am having a bit of trouble trying to double up on slashes in a file path. What I am trying to do is very similar to the code below: <? $var = "\\wusais\Intranets\Intranets\fpdb\pdf\weinig\00505882.pdf"; $new = preg_replace("\\", "\\\", "$var"); ?> Code above produces the following error:
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9543
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10237
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9077
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7567
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4144
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.