Text File
-
How can i store a text file at clients machine in asp.net Amit
-
How can i store a text file at clients machine in asp.net Amit
try this.................. Public Function DownLoadMyFile(ByVal sPath As String, ByVal sName As String) Try 'If chkInOut.Checked = False Then Dim pstrFilePath As String pstrFilePath = sPath If IO.File.Exists(pstrFilePath) Then Dim myFileInfo As IO.FileInfo Dim StartPos As Long = 0, FileSize As Long, EndPos As Long myFileInfo = New IO.FileInfo(pstrFilePath) FileSize = myFileInfo.Length EndPos = FileSize HttpContext.Current.Response.Clear() HttpContext.Current.Response.ClearHeaders() HttpContext.Current.Response.ClearContent() Dim Range As String = HttpContext.Current.Request.Headers("Range") If Not ((Range Is Nothing) Or (Range = "")) Then Dim StartEnd As Array = Range.Substring(Range.LastIndexOf("=") + 1).Split("-") If Not StartEnd(0) = "" Then StartPos = CType(StartEnd(0), Long) End If If StartEnd.GetUpperBound(0) >= 1 And Not StartEnd(1) = "" Then EndPos = CType(StartEnd(1), Long) Else EndPos = FileSize - StartPos End If If EndPos > FileSize Then EndPos = FileSize - StartPos End If HttpContext.Current.Response.StatusCode = 206 HttpContext.Current.Response.StatusDescription = "Partial Content" HttpContext.Current.Response.AppendHeader("Content-Range", "bytes " & StartPos & "-" & EndPos & "/" & FileSize) End If HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" & sName) HttpContext.Current.Response.WriteFile(Server.HtmlEncode(pstrFilePath), StartPos, EndPos) HttpContext.Current.Response.End() End If Catch ex As OleDb.OleDbException Throw Catch ex As Exception Throw End Try End Function VMSSanthosh
-
How can i store a text file at clients machine in asp.net Amit
For clarification, your code doesn't have direct access to the clients machine. You have to send the file in something that the client would have to OK the download of and pick the spot to save it. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome