StreamWriter

G

Guest

I have just ported some sample code from xp to windows 2k and received a
system not supported exception when trying to save a string to a .txt file.
It breaks on line 2 below. It says the given file path is not supported. I
cannot see why not as I can paste it into the run dialog and it opens the
directory.

Dim oSW As StreamWriter
oSW = New StreamWriter(txtPollDirectory.Text + LogName)
 
G

Guest

sorry i forgot to say the string in txtPollDirectory is
"C:\QDIMIS_RECON\MISRE_FTP_Logs"
 
G

Guest

It's something to do with unauthorixed access to the C drive.
The machine it worked on was my dev computer.
The Win 2k machine is a networked pc at work.
I'ld rather fix it myself than get the helpdesk introduced and wait 2 weeks.

Here is all code

Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnStart.Click
Dim today As Date = today.Now.ToLongDateString
Dim time As Date = today.Now.ToShortTimeString
Dim LogName As String = "Log_" + today.Now.ToLongDateString + " " +
today.Now.ToShortTimeString + ".txt"

Dim oSW As StreamWriter
oSW = New StreamWriter(txtPollDirectory.Text) ' + LogName)

oSW.WriteLine(LogBox.Text)
oSW.Flush()
oSW.Close()

MessageBox.Show("Log File created.", "MIS RECON Engine",
MessageBoxButtons.OK, MessageBoxIcon.Information)

End Sub
 
G

Guest

sorry guys just fixed it, the filename had a time 16:40 and it dont like ":"

thx though
 
H

Herfried K. Wagner [MVP]

marcmc said:
sorry guys just fixed it, the filename had a time 16:40 and it dont like
":"

In addition to your replies: I suggest to use 'System.IO.Path.Combine' to
combine paths and filenames, and the '&' operator to concatenate strings.
 

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