ArtK99

I have a .Net 2.0 application written in VB. In general it seems to run fine in Vista but at one point it writes a temp file. At this point my application either generates an exception or completely crashes Vista. The code to write the temp file looks like this:

Dim strFilename As String = System.IO.Path.GetTempFileName()
While strFilename.Substring(strFilename.Length - 1, 1) <> "\"
strFilename = strFilename.Substring(0, strFilename.Length - 1)
End While
strFilename = strFilename & "AMMsg" & CurrentMessageID & ".html"
Dim objFS As New System.IO.FileStream(strFilename, _
System.IO.FileMode.Create, _
System.IO.FileAccess.Write)
' Opens stream and begins writing
Dim Writer As New System.IO.StreamWriter(objFS)
Writer.BaseStream.Seek(0, System.IO.SeekOrigin.End)
Writer.WriteLine(Data)
Writer.Flush()
' Closes and returns temp path
Writer.Close()

The file being written is .html. The purpose is to then open the temp file in a browser. The code to do this is System.Diagnostics.Process.Start(strFilename ).

This all works great when my application runs in XP. Any idea what's going on here


Re: General Windows Vista Development Issues Crashing when creating temp file

AndyCadley

The path returned by GetTempFilename() isn't meant to be modified directly. For what you appear to be trying to do you'd be better calling GetTempPath() to identify the temp directory and then using System.IO.Path.Combine to add your preferred filename.



Re: General Windows Vista Development Issues Crashing when creating temp file

ArtK99

It turns out that the error is being thrown at the line:

System.Diagnostics.Process.Start(strFilename )

That's when I'm "running" the html file which causes the default browser to load. Here's the strange thing... At the same time the error is thrown, the browser does open and display the html file. This is very puzzling since the error indicates file not found

Art