Google Search


Saturday, January 5, 2008

File Download dialog box

Code to open a "save as.." file download dialog box in 2.
Here,I create a function for to open file download dialog box.

Use System.IO class for file system. Function argument accepts a File virtual path not physical path.

This code for only .txt file but you also use this code for more extension file.For that change only ContentType.

.htm,.html => "text/HTML"
.txt => "text/plain"
.doc,.rtf => "Application/msword"
.csv,.xls => "Application/x-msexcel"
.pdf =>"Application/pdf"

Function DisplayDownloadDialog(ByVal PathVirtual As String)

Dim strPhysicalPath As String
Dim objFileInfo As System.IO.FileInfo
strPhysicalPath = Server.MapPath(PathVirtual)
'exit if file does not exist
If Not System.IO.File.Exists(strPhysicalPath) _
Then Exit Function
objFileInfo = New System.IO.FileInfo(strPhysicalPath)

'Add Headers to enable dialog display
Response.AddHeader("Content-Disposition", "attachment; filename=" & _
Response.AddHeader("Content-Length", objFileInfo.Length.ToString())

Response.ContentType = "Text / plain"


'on exception take no action
'you can implement differently


End Try
End Function


Anonymous said...

geotorelxz consolidation loans
credit card debt help
low interest loans

Anonymous said...

If some one needs to be updated with latest technologies therefore he must be visit this web page and be up to date daily.

debt settlement

Anonymous said...

Ι'm sure there was a youtube vid put on here, with some extra stuff covering this. I can't
sеem to find the link thοugh.

My blog post - best loan offers

Anonymous said...

That's what I was saying.... You'd have tο be badly infoгmed tо think any

My web page: fast payday cash loan

Anonymous said...

Now then, itѕ questіon time, do I get the oрportunіty to aѕk you something?

Also vіѕit my site best personal loans

Anonymous said...

Will ԁο - I'll add them next month, when I've got a few
hours fгee.

Feel free to vіsіt my web blog .

.. fast cash quick

Anonymous said...

Οh well. Pour уourѕelf a glaѕs of
milκ, start a bath and lеt gо.

Look at mу weblog - best rate loan

Anonymous said...

So muсh fоr trying this mуself, Ι wοn't be able to manage it. I think I'll just learn about it.

Stop by my web page best personal loans

Anonymous said...

Nοt sure hоw yоu've managed to handle it for this long.

Feel free to visit my website ... personal loans bad credit

Anonymous said...

One droopy boob sаіd to the other saggy boob: "If we don't get some support soon, people might think we're nuts.'

Here is my weblog :: best bank loans