By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,436 Members | 2,958 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,436 IT Pros & Developers. It's quick & easy.

How to create a new empty text file?

P: n/a
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
*-----------------------*
Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
"JenHu" <je**********@hotmail-dot-com.no-spam.invalid> wrote in message
news:41**********@Usenet.com...
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
*-----------------------*

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.