How do I create a temporary file on a server?

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.
 
L

lwoods

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
 
T

Terry Burns

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.
 
L

lwoods

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top