Question : Read fields from an html file back into a Windows Form

I did a little tool in VB to create/edit the .html version of an MS Outlook signature.   It uses a StreamWriter to write the string below to a .htm file in the \Microsoft\Signatures folder.
(the code snippet has a formatted version for readability)

Writing the file works fine, but I want to read the existing file into the tool so the second time someone runs it they don't have to re-type everything in.  If the "WorkForceOne.htm" file exists the tool should parce the appropriate fields back into the text boxes of the tool.  

In any existing file all of the numbers in braces will be replaced with the persons actual inforation, Name, phone number, etc.  That's what I'd like to pupulate the text boxes of the VB form with when it's launched and it finds an existing file.

Dim htmEmailSignature As String = "<html><head><title>WorkForce One Signature</title><style type=""text/css"" media=""screen""> a {font-family:Arial, san-serif;cursor: auto;} a:link {text-decoration:none; color: black;} a:visited {text-decoration:none; color: black;} a:hover {text-decoration: none; color: #ff9900; font-weight:bold;} a:active {color: #ff0000;text-decoration: none;} body {font-family:Arial; color:#000000; } </style></head><body><table cellspacing=""0"" cellpadding=""1""><tr><td valign=""top"" align=""left""><p><a href=""http://www.wf1broward.com/""><img src=""WF1Logo.bmp"" border=""0"" height=""79"" width=""235"" hspace=""12"" align=""left"" /></a></p></td><td width=""600"" style=""font-size:x-small; color:#000000;""><p><span style=""color:#006d75; font-weight:bold;"">{0}</span><br>{1}<br><span style=""color:#8c004c;"">{2}</span></p><p>{3}<br>{4}<br>{5}</p><p><a href=""mailto:{6}"" style=""text-decoration:none""><span style=""color:#8c004c; font-weight:bold;"">{6}</span></a><br><a href=""{7}"">{7}</a></p></td></tr></table><br /><span style=""color:#bbbbbb; font-size:xx-small;"">This message is intended only for the use of the individual or entity to which it is addressed and may contain information that is privileged, confidential and exempt from disclosure under applicable law. <br></span></body></html>"

Code bits:

Dim sW As New System.IO.StreamWriter("C:\Documents and Settings\" & eV & "\Application Data\Microsoft\Signatures\WorkForceOne.htm")

        i = i.Replace("{1}", txtTitle.Text)
        i = i.Replace("{2}", txtPhone.Text)
        i = i.Replace("{3}", txtAddress.Text)
        i = i.Replace("{4}", txtCityStateZip.Text)
        i = i.Replace("{5}", txtFax.Text)
        i = i.Replace("{6}", txtEmail.Text)
        i = i.Replace("{7}", txtWebURL.Text)

sW.WriteLine(i)
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
<html>
  <head>
    <title>WorkForce One Signature
    </title>
    <style type="" text/css"" media="" screen""> a {font-family:Arial, san-serif;cursor: auto;} a:link {text-decoration:none; color: black;} a:visited {text-decoration:none; color: black;} a:hover {text-decoration: none; color: #ff9900; font-weight:bold;} a:active {color: #ff0000;text-decoration: none;} body {font-family:Arial; color:#000000; } 
    </style>
  </head>
  <body>
    <table cellspacing="" 0"" cellpadding="" 1"">
      <tr>
        <td valign="" top"" align="" left"">
          <p>
            <a href="" http://www.wf1broward.com/"">
              <img src="" WF1Logo.bmp"" border="" 0"" height="" 79"" width="" 235"" hspace="" 12"" align="" left""/>
            </a>
          </p>
        </td>
        <td width="" 600"" style="" font-size:x-small; color:#000000;"">
          <p>
            <span style="" color:#006d75; font-weight:bold;"">{0}
            </span>
            <br>{1}
            <br>
            <span style="" color:#8c004c;"">{2}
            </span>
          </p>
          <p>{3}
            <br>{4}
            <br>{5}
          </p>
          <p>
            <a href="" mailto:{6}"" style="" text-decoration:none"">
              <span style="" color:#8c004c; font-weight:bold;"">{6}
              </span>
            </a>
            <br>
            <a href="" {7}"">{7}
            </a>
          </p>
        </td>
      </tr>
    </table>
    <br/>
    <span style="" color:#bbbbbb; font-size:xx-small;"">This message is intended only for the use of the individual or entity to which it is addressed and may contain information that is privileged, confidential and exempt from disclosure under applicable law. 
      <br>
    </span>
  </body>
</html>

The completed file written out may look like this:

<html>
<head>
  <meta name="generator" content=
  "HTML Tidy for Linux/x86 (vers 11 February 2007), see www.w3.org">

  <title>WorkForce One Signature</title>
  <style type="text/css" media="screen">
a {font-family:Arial, san-serif;cursor: auto;} a:link {text-decoration:none; color: black;} a:visited {text-decoration:none; color: black;} a:hover {text-decoration: none; color: #ff9900; font-weight:bold;} a:active {color: #ff0000;text-decoration: none;} body {font-family:Arial; color:#000000; } 
  </style>
</head>

<body>
  <table cellspacing="0" cellpadding="1">
    <tr>
      <td valign="top" align="left">
        <p><a href="http://www.wf1broward.com/"><img src="WF1Logo.bmp" border="0" 
        height="79" width="235" hspace="12" align="left"></a></p>
      </td>

      <td width="600" style="font-size:x-small; color:#000000;">
        <p><span style="color:#006d75; font-weight:bold;">Dave Megnin</span><br>
        Systems Analyst / Programmer<br>
        <span style="color:#8c004c;">(954) 202-3830 Ext. 3030</span></p>

        <p>6301 NW 5th Way, Suite 3000<br>
        Fort Lauderdale, FL 33309<br>
        Fax: (954) 202-3620</p>

        <p><a href="mailto:[email protected]" style=
        "text-decoration:none"><span style=
        "color:#8c004c; font-weight:bold;">[email protected]</span></a><br>
        <a href="www.wf1broward.com">www.wf1broward.com</a></p>
      </td>
    </tr>
  </table><br>
  <span style="color:#bbbbbb; font-size:xx-small;">This message is intended only for the
  use of the individual or entity to which it is addressed and may contain information
  that is privileged, confidential and exempt from disclosure under applicable
  law.<br></span>
</body>
</html>

Answer : Read fields from an html file back into a Windows Form

In general , clean up the OS drive and do a full backup of it regularly ( once a week ), incremental dailies with system state
That should at least recover the  OS for a server, as long as there are not any programs that require data on a different drive/partition.

Some stuff requires being backed up together such as Exchange data, SQL etc.

I hope this helps !
Random Solutions  
 
programming4us programming4us