adamsinline
Newcomer
- Joined
- Jan 19, 2005
- Messages
- 5
OpenFileDialog in asp
Is there a way to use this code with vb.net asp ?? The problem is there is no OpenFileDialog control in vb.net asp. Can I get around this ?
Is there a way to use this code with vb.net asp ?? The problem is there is no OpenFileDialog control in vb.net asp. Can I get around this ?
Originally from http://www.xtremedotnettalk.com/showthread.php?t=83319dynamic_sysop said:take a look at the OpenFileDialog and the System.IO.StreamReader / StreamWriter classes , here's an example i knocked up for you ...
Visual Basic:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim oDialog As New OpenFileDialog() Dim sReader As IO.StreamReader '/// to open the file for reading Dim sWriter As IO.StreamWriter '/// to write to the file Dim strText As String With oDialog .InitialDirectory = "C:\" .Filter = "textfiles|*.txt" If .ShowDialog = DialogResult.OK Then sReader = New IO.StreamReader(New IO.FileStream(.FileName, IO.FileMode.Open)) While Not sReader.Peek = -1 strText += sReader.ReadLine.Substring(1) & Environment.NewLine '/// append each line of your file's text Minus the first character to a string buffer. End While sReader.Close() '/// close the opened file. sWriter = New IO.StreamWriter(.FileName, False) '/// False will overwrite the existing file. sWriter.Write(strText) sWriter.Close() End If End With End Sub
Last edited by a moderator: