How to create a new empty text file?

J

JenHu

Hi experts,

I want to create a new empty text file after I upload a file to
the desination. Then I need to read each line from the uploaded file
and write the lines which first character <>'6' to the new
file.
Can someone show me how to do this? First of all, what is the syntax
to create a new text file? Thank you.

This is the funcation for upload file:
-----------------------------------------------------------------

Sub Upload_Click(ByVal source As Object, ByVal e As EventArgs)
Dim savePath As String = "C:\temp\"
Dim postedFile = uploadedFile.PostedFile
Dim filename As String =
Path.GetFileName(postedFile.FileName)
Dim contentType As String = postedFile.ContentType
Dim contentLength As Integer = postedFile.ContentLength
If Not (uploadedFile.PostedFile Is Nothing) Then
Try
'upload file to destination directory
postedFile.SaveAs(savePath & filename)
message.Text = postedFile.Filename & " uploaded"
& _
"<br>content type: " & contentType &
_
"<br>content length: " &
contentLength.ToString()
Catch exc As Exception
message.Text = "Failed uploading file"
End Try
End If
'Create a new text file

End Sub

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 
J

John Puopolo

Hi...

If you are using ASP.NET to upload the file, you can use the HtmlInputFile
control.
On the server, the file appears as an HttpPostedFile and can be retreived
by:

upLoadControl.PostedFile.

So, if you wanted to save the uploaded file, you could simply do something
like:

upLoadControl.PostedFile.SaveAs(filename);

Hope this helps,

John Puopolo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top