How to create a new empty text file?

  • Thread starter Thread starter JenHu
  • Start date Start date
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
*-----------------------*
 
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

Similar Threads

Upload File - test for valid file type 3
Can't Figure Out What is Wrong 6
Upload/Download Security Question 2
ASP.NET SQL Bulk Insert 0
Upload large data 2
rename file on upload 2
Uploading Files 6
file size 1

Back
Top