Re: Closing a file and the form
From: Herfried K. Wagner [MVP] (hirf-spam-me-here_at_gmx.at)
Date: 08/19/04
- Next message: Herfried K. Wagner [MVP]: "Re: Closing a file and the form"
- Previous message: Brian Henry: "Re: Parseing data in CSV files"
- In reply to: Kelly: "Re: Closing a file and the form"
- Next in thread: Kelly: "Re: Closing a file and the form"
- Reply: Kelly: "Re: Closing a file and the form"
- Messages sorted by: [ date ] [ thread ]
Date: 19 Aug 2004 20:08:11 +0200
Kelly,
* "Kelly" <kelly.hauser@amerock.com> scripsit:
> I just read my post and I hope it didn't come across as snarky or rude. :)
You didn't.
> I figured that I'd have to launch Notepad.exe in order to open the file (if
> it was a .txt file anyway). Is there another way to open a simple txt file?
> (I'm also going to try this with .xls and .doc files in the same way.)
The meaning of the term "open" in relation to files is overloaded:
(1) Opening a file means that you start an application that is able to
read/process/display/edit the file. In this case, the /user/ opens
the file, for example, by doubleclicking it in Explorer. This can
be done in VB using the 'Shell' command too. This command will
launch an application with a certain file.
(2) Opening a file from the developer point of view means to perform
steps that are necessary to access the data stored in a file and/or
make it ready for reading data from the file and/or writing data to
the file. In VB.NET, this can be done using 'FileOpen', etc., or
the 'System.IO.StreamWriter'/'System.IO.StreamReader' class.
I assume that you want to do (1).
> I'm really new at .NET and we just started using it here at work (from vb6)
> so I thought I'd start writing a few programs to get a feel for the new
> language. All I'm really trying to do is create a csv file.
There is everything OK with that. Glad to see that people are using
VB.NET.
> I figured I could have the user input the data (in the txtboxes) and have
> them pick which type of file they'd like to save it to (.doc, .txt. or .xls)
> and then save the data. For right now, I'm only testing this for txt files
> and figured I'd have to launch Notepad.exe to get the txt files to open at
> all.
Text files can be simply written using 'FileOpen', etc., or the
'Stream*' classes. For Excel files and other binary formats, it's not
as easy because often the formats are not documented. In these cases,
Office automation can be used to write the data to the file.
> The problem is, I'm unclear of how to close the file once the user has
> selected it to save to, you know? They should be able to browse to the file,
> "test.txt", choose it, and click OK (from the file save dialog).
OK.
> I really don't even need for the user to SEE the file open up at all. All
> that really needs to happen is the user selects the file, clicks OK and it's
> done. But, my form (with the txtboxes and cmd button) and the file they
> selected (test.txt) stays open.
For simple text files, skip the 'Shell(...)' line.
-- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
- Next message: Herfried K. Wagner [MVP]: "Re: Closing a file and the form"
- Previous message: Brian Henry: "Re: Parseing data in CSV files"
- In reply to: Kelly: "Re: Closing a file and the form"
- Next in thread: Kelly: "Re: Closing a file and the form"
- Reply: Kelly: "Re: Closing a file and the form"
- Messages sorted by: [ date ] [ thread ]