-
Opening a file to read.
Hi I have realized that I have forgotten to open the file in .NET, how do
you correctly open the file? right now I have this,
strFile = Open InputBox("Location of File", "File Location") for append as
1
and it doesnt recognize Open as a valid command...Thanks
-
Re: Opening a file to read.
Hi,
You probably want to do the following:
dim strFileName as String
strFileName = InputBox("Location of File", "File Location")
'To read a file
dim fileReader as System.IO.StreamReader
dim contents as String
try
fileReader = New System.IO.StreamReader(strFileName)
contents = fileReader.ReadToEnd
catch ex as Exception
Msgbox (Ex.Message)
Finally
'Your clean up code here
fileReader.Close
End Try
'To write to file
dim fileWriter as System.IO.StreamWriter
try
fileWriter = new System.IO.StreamWriter(strFileName)
fileWriter.Write("Your text")
catch ex as Exception
MsgBox(ex.Message)
Finally
'Your clean up code here
fileWriter.Close
End Try
Let us know if you have more questions
-Shamez
VB.Net Program Manager
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Help" <Help@help.com> wrote in message news:3d108457$1@10.1.10.29...
>
> Hi I have realized that I have forgotten to open the file in .NET, how do
> you correctly open the file? right now I have this,
> strFile = Open InputBox("Location of File", "File Location") for append as
> 1
>
> and it doesnt recognize Open as a valid command...Thanks
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks