Reading and writing files in one click
Reading and writing files in one click
Reading and writing files in one click
Reading and writing files in one click
Reading and writing files in one click
Reading and writing files in one click Reading and writing files in one click Reading and writing files in one click Reading and writing files in one click Reading and writing files in one click Reading and writing files in one click Reading and writing files in one click Reading and writing files in one click
Reading and writing files in one click Reading and writing files in one click
Reading and writing files in one click
Go Back  Xtreme Visual Basic Talk > > > Reading and writing files in one click


Reply
 
Thread Tools Display Modes
  #1  
Old 06-12-2006, 07:28 AM
85882 85882 is offline
Newcomer
 
Join Date: Apr 2004
Location: Barrie, Ontario, Canada
Posts: 5
Default Reading and writing files in one click


hey,

Ok, I want that in one click it will load the file decode the binary into ascii (which it already does) and then saves the ascii output in a text file. The problem that I get is that it doesn't save the output into a file because vb.net is complaining that the file is in use. Could anybody help me?

Thanks!

*OOPS* Wrong forum...this should be put into the .NET File I/O forum. Sorry about that!
Reply With Quote
  #2  
Old 06-13-2006, 01:40 AM
Allen G's Avatar
Allen G Allen G is offline
Centurion
 
Join Date: Jul 2004
Location: Arlington, Texas
Posts: 189
Lightbulb

Quote:
Originally Posted by 85882
hey,

Ok, I want that in one click it will load the file decode the binary into ascii (which it already does) and then saves the ascii output in a text file. The problem that I get is that it doesn't save the output into a file because vb.net is complaining that the file is in use. Could anybody help me?

Thanks!

*OOPS* Wrong forum...this should be put into the .NET File I/O forum. Sorry about that!
Code:
        Dim reader As StreamReader
        Dim writer As StreamWriter
        Dim data As String

        Try
            reader = New StreamReader("file.txt", System.Text.Encoding.Default)
            data = reader.ReadToEnd
            Call reader.Close() 'File is now closed, not in use.

            writer = New StreamWriter("file.txt", False, System.Text.Encoding.Default)
            Call writer.Write(data)
            Call writer.Close() 'File is now closed, not in use.

        Catch ex As Exception
            Debug.WriteLine(ex.ToString, "I/O Error")
        End Try
Use the Close method to close the file, before writing to it.
Reply With Quote
  #3  
Old 06-13-2006, 01:01 PM
85882 85882 is offline
Newcomer
 
Join Date: Apr 2004
Location: Barrie, Ontario, Canada
Posts: 5
Default

Ok.Thanks. Now I have another question. How do I open multiple files in one click and save the output in one big file. I want that the program searches for for a files in a specific folder and then open each of them and then save the contents oin one file in other folder. How do I do that?
Reply With Quote
  #4  
Old 06-16-2006, 04:46 AM
CForrester CForrester is offline
Regular
 
Join Date: Jun 2005
Location: Montreal, Quebec
Posts: 96
Default

You could try setting OpenFileDialog's Multiselect to 1, then use a For Each to loop through each file and load its text into an array, then loop through each element in the array and write it to the same file.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Reading and writing files in one click
Reading and writing files in one click
Reading and writing files in one click Reading and writing files in one click
Reading and writing files in one click
Reading and writing files in one click
Reading and writing files in one click Reading and writing files in one click Reading and writing files in one click Reading and writing files in one click Reading and writing files in one click Reading and writing files in one click Reading and writing files in one click
Reading and writing files in one click
Reading and writing files in one click
 
Reading and writing files in one click
Reading and writing files in one click
 
-->