I'm trying to write a webpage that processes a clients file and then returns the file to the client.
When the file processing is completed a completion message is output to the clients browser and a
button is provided for the client to request the processed file.
The following sub sends the file back to the client:
Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles ButtonSendClientFile.Click
Dim attachName As String = "attachment; filename= " & Label1Copyname.Text Dim appPath As String = Request.PhysicalApplicationPath Dim saveDir As String = "ReturnToClientFiles\" Dim fileName As String = Label1Copyname.Text ' Get the name of the file to upload. Dim savePath As String = appPath + saveDir + fileName
Response.ContentType = "text/plain" Response.AppendHeader("Content-Disposition", attachName) Response.TransmitFile(savePath) Response.End() End Sub
The next thing I need to do is remove the clients file from my server folder "ReturnToClientFiles"
If I add the line:
My.Computer.FileSystem.DeleteFile(savePath)
nothing happens, and wherever I place it - no result (except errors).
How do I achieve wiping the file after sending to client on a single button click event?
gridlocked
Member
1 Points
4 Posts
Deleting a client file after TransmitFile back to client
Apr 06, 2012 11:16 AM|LINK
I'm trying to write a webpage that processes a clients file and then returns the file to the client.
When the file processing is completed a completion message is output to the clients browser and a
button is provided for the client to request the processed file.
The following sub sends the file back to the client:
Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles ButtonSendClientFile.Click
Dim attachName As String = "attachment; filename= " & Label1Copyname.Text
Dim appPath As String = Request.PhysicalApplicationPath
Dim saveDir As String = "ReturnToClientFiles\"
Dim fileName As String = Label1Copyname.Text ' Get the name of the file to upload.
Dim savePath As String = appPath + saveDir + fileName
Response.ContentType = "text/plain"
Response.AppendHeader("Content-Disposition", attachName)
Response.TransmitFile(savePath)
Response.End()
End Sub
The next thing I need to do is remove the clients file from my server folder "ReturnToClientFiles"
If I add the line:
My.Computer.FileSystem.DeleteFile(savePath)
nothing happens, and wherever I place it - no result (except errors).
How do I achieve wiping the file after sending to client on a single button click event?
DarrellNorto...
All-Star
86555 Points
9624 Posts
Moderator
MVP
Re: Deleting a client file after TransmitFile back to client
Apr 06, 2012 02:34 PM|LINK
Try this:
Darrell Norton's Blog
Please click "Mark as Answer" if this helped you.