Problem reading css file

C

Co

Hi All,

I'm trying to create a html file from VB.NET.
But when I run the code it stops at the next line:

Dim cssFile As String = Path.Combine(Path.GetDirectoryName("C:\"),
"preview.css")

If File.Exists(cssFile) Then
sb.Append("<style>" & vbLf)
sb.Append(My.Computer.FileSystem.ReadAllText(cssFile))
sb.Append("</style>" & vbLf)
End If

The file exists and has the following content:

..tableheader
{
font-size: 14px;
color: White;
background-color: #2c7393;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
..td {
font-size: 11px;
color: #666666;
background-color: #F0F0F0;
font-family: Verdana, Arial, Helvetica, sans-serif;
text-decoration: none;

border-bottom-style:none;
}
..tr {
font-size: 11px;
color: #666666;
background-color: #F0F0F0;
font-family: Verdana, Arial, Helvetica, sans-serif;
text-decoration: none;
border-bottom-style:none;
}
..form {
font-size: 11px;
font-family: Verdana, Arial, Helvetica, sans-serif;
margin: 0px;
color: #000000;
}

I don't understand what is happening.
Can someone help me?

Marco
 
A

Armin Zingler

Co said:
Hi All,

I'm trying to create a html file from VB.NET.
But when I run the code it stops at the next line:

Why does it stop? .... Found it out: ArgumentNullException
Dim cssFile As String = Path.Combine(Path.GetDirectoryName("C:\"),
"preview.css")

Documentation of the return value of GetDirectoryName says "...Nothing if
path denotes a root directory", that is, "C:\" _is_ a directory, so you
don't have to get the directory from the path.
sb.Append(My.Computer.FileSystem.ReadAllText(cssFile))

Why not the straight way? System.IO.File.ReadAllText. My.Crap is only an
indirection.



Armin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top