How do I create a temporary file on a server?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to create a temporary file on a server. How do I do it? I tried
using IO.Path but it created a local file; i.e., file://C:......


Depending on how large the file is... you can also use a memorystream.
 
I need to create a temporary file on a server. How do I do it? I tried
using IO.Path but it created a local file; i.e., file://C:......

TIA,

lwoods
 
Here is an example.
Dim filePath As String = Server.MapPath(ArticleStorage) & "\Art" &
txtArticleID.Text & "\" & "Art" & txtArticleID.Text & ".html"



If System.IO.File.Exists(filePath) Then

System.IO.File.Delete(filePath)

End If

' Create an instance of StreamWriter to write text to a file.

Dim sw As System.IO.StreamWriter = New System.IO.StreamWriter(filePath)

Dim hWriter As System.Web.UI.HtmlTextWriter

hWriter = New System.Web.UI.HtmlTextWriter(sw)

'// Continiue to write and then close it.
 
Thanks, Terry...


Terry Burns said:
Here is an example.
Dim filePath As String = Server.MapPath(ArticleStorage) & "\Art" &
txtArticleID.Text & "\" & "Art" & txtArticleID.Text & ".html"



If System.IO.File.Exists(filePath) Then

System.IO.File.Delete(filePath)

End If

' Create an instance of StreamWriter to write text to a file.

Dim sw As System.IO.StreamWriter = New System.IO.StreamWriter(filePath)

Dim hWriter As System.Web.UI.HtmlTextWriter

hWriter = New System.Web.UI.HtmlTextWriter(sw)

'// Continiue to write and then close it.
 

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

Back
Top