T
tshad
I have a function that downloads a file to the users computer and it works
fine.
The problem is that I then want the program to rename the file (file.move)
to the same name plus todays date.
The problem is that when you run the program it gets to the:
Response.AddHeader("Content-Disposition", "attachment; filename=" +
file.Name)
and this does something to the program and it will finish the response
section to write file but never does anything else.
Following is the Sub and it works fine, but never does any code after the
response section. Not the Trace and not the section that does the rename.
************************************
Sub GetFileDownload(strRequest as String)
trace.warn("in file download")
if (strRequest <> "")
' get absolute path of the file
Dim file as System.IO.FileInfo = new System.IO.FileInfo(strRequest)
' if the file exists on the server
if (file.Exists)
' set appropriate headers
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" +
file.Name)
Response.AddHeader("Content-Length", file.Length.ToString())
Response.ContentType = "application/octet-stream"
Response.WriteFile(file.FullName)
Response.End()
trace.warn("inside Download strRequest = " & strRequest)
' Dim newFile as System.IO.FileInfo = new System.IO.FileInfo(strRequest &
" " & DateTime.Now.Month & "_" & DateTime.Now.Day & "_" & DateTime.Now.Year)
' if not newFile.Exists
' System.IO.File.Move(file.FullName.ToString(),file.DirectoryName & "\"
& strRequest & " " & DateTime.Now.Month & "_" & DateTime.Now.Day & "_" &
DateTime.Now.Year)
' end if
else
' if file does not exist
StatusMessage.Text = "This file does not exist."
end if
else
StatusMessage.Text = "Please provide a file to download."
end if
trace.warn("At end of Download")
end sub
*************************************************
Why does this happen? I assume it has something to the HTTP pipe.
How can I get this to rename the file after it copies it?
Thanks,
Tom
fine.
The problem is that I then want the program to rename the file (file.move)
to the same name plus todays date.
The problem is that when you run the program it gets to the:
Response.AddHeader("Content-Disposition", "attachment; filename=" +
file.Name)
and this does something to the program and it will finish the response
section to write file but never does anything else.
Following is the Sub and it works fine, but never does any code after the
response section. Not the Trace and not the section that does the rename.
************************************
Sub GetFileDownload(strRequest as String)
trace.warn("in file download")
if (strRequest <> "")
' get absolute path of the file
Dim file as System.IO.FileInfo = new System.IO.FileInfo(strRequest)
' if the file exists on the server
if (file.Exists)
' set appropriate headers
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" +
file.Name)
Response.AddHeader("Content-Length", file.Length.ToString())
Response.ContentType = "application/octet-stream"
Response.WriteFile(file.FullName)
Response.End()
trace.warn("inside Download strRequest = " & strRequest)
' Dim newFile as System.IO.FileInfo = new System.IO.FileInfo(strRequest &
" " & DateTime.Now.Month & "_" & DateTime.Now.Day & "_" & DateTime.Now.Year)
' if not newFile.Exists
' System.IO.File.Move(file.FullName.ToString(),file.DirectoryName & "\"
& strRequest & " " & DateTime.Now.Month & "_" & DateTime.Now.Day & "_" &
DateTime.Now.Year)
' end if
else
' if file does not exist
StatusMessage.Text = "This file does not exist."
end if
else
StatusMessage.Text = "Please provide a file to download."
end if
trace.warn("At end of Download")
end sub
*************************************************
Why does this happen? I assume it has something to the HTTP pipe.
How can I get this to rename the file after it copies it?
Thanks,
Tom