Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Text File

Text File

Scheduled Pinned Locked Moved Database
csharpasp-netquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sood_is_in
    wrote on last edited by
    #1

    How can i store a text file at clients machine in asp.net Amit

    V D 2 Replies Last reply
    0
    • S sood_is_in

      How can i store a text file at clients machine in asp.net Amit

      V Offline
      V Offline
      VMSSanthosh
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • S sood_is_in

        How can i store a text file at clients machine in asp.net Amit

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups