Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 136,237 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 2,267 people online right now. Registration is fast and FREE... Join Now!




get streamwriter destination

 
Reply to this topicStart new topic

get streamwriter destination

Damage
13 Oct, 2008 - 05:48 PM
Post #1

D.I.C Addict
Group Icon

Joined: 5 Jun, 2008
Posts: 738



Thanked: 7 times
Dream Kudos: 75
My Contributions
this is really a silly little question but is there a way to get a streamwriters output file?

something like
CODE

lblHTMLStatus.Text = "HTML written to " & objStreamWriter.tostring


would change the label to "HTML written to c:\TestFile"

silly i know but just like to see if you can, I haven't found a way yet.
User is offlineProfile CardPM
+Quote Post

jacobjordan
RE: Get Streamwriter Destination
13 Oct, 2008 - 06:13 PM
Post #2

class Me : Perfection
Group Icon

Joined: 11 Jun, 2008
Posts: 1,163



Thanked: 32 times
Dream Kudos: 1625
My Contributions
I do not believe so. You will have to store the path in a variable or something when you declare the stream.
User is offlineProfile CardPM
+Quote Post

Damage
RE: Get Streamwriter Destination
13 Oct, 2008 - 06:20 PM
Post #3

D.I.C Addict
Group Icon

Joined: 5 Jun, 2008
Posts: 738



Thanked: 7 times
Dream Kudos: 75
My Contributions
thats what I'm doing now tongue.gif was just curious if theres another way
User is offlineProfile CardPM
+Quote Post

jacobjordan
RE: Get Streamwriter Destination
13 Oct, 2008 - 06:25 PM
Post #4

class Me : Perfection
Group Icon

Joined: 11 Jun, 2008
Posts: 1,163



Thanked: 32 times
Dream Kudos: 1625
My Contributions
It's just seems weird. It's such a simple thing, you think there has to be something to do it, but neither of us can find anything.
User is offlineProfile CardPM
+Quote Post

DeCompile
RE: Get Streamwriter Destination
13 Oct, 2008 - 06:45 PM
Post #5

D.I.C Head
**

Joined: 20 Jul, 2008
Posts: 180



Thanked: 6 times
My Contributions
Why not try:

lblHTMLstatus.text = "HTML written to " & objStreamWriter.name

EXAMPLE:

Dim file As New FileStream("test.txt", FileMode.Create, FileAccess.Write)
Dim s As New StreamWriter(file)
s.WriteLine("TEST")
s.WriteLine("LINE 2")
s.Close()
Label1.Text = file.Name

This post has been edited by DeCompile: 13 Oct, 2008 - 06:46 PM
User is offlineProfile CardPM
+Quote Post

Damage
RE: Get Streamwriter Destination
13 Oct, 2008 - 07:06 PM
Post #6

D.I.C Addict
Group Icon

Joined: 5 Jun, 2008
Posts: 738



Thanked: 7 times
Dream Kudos: 75
My Contributions
its not quite the same thing. You're using a filestream which has a method to return the name used in the constuctor. The streamWriter class doesn't seem to have an equivalent method. As jacob said it's just kinda weird that something so simple isn't built in...although it's probably because it is so simple that they over looked it.
User is offlineProfile CardPM
+Quote Post

DeCompile
RE: Get Streamwriter Destination
13 Oct, 2008 - 07:26 PM
Post #7

D.I.C Head
**

Joined: 20 Jul, 2008
Posts: 180



Thanked: 6 times
My Contributions
So if he's using the streamwriter class.. doesn't he have to define the filename?

eg.

dim filename as string = "C:\test.txt"
User is offlineProfile CardPM
+Quote Post

Damage
RE: Get Streamwriter Destination
13 Oct, 2008 - 07:33 PM
Post #8

D.I.C Addict
Group Icon

Joined: 5 Jun, 2008
Posts: 738



Thanked: 7 times
Dream Kudos: 75
My Contributions
yeah you do but what I'm looking for is a method exactly like the one you showed for the filestream, instead of using a variable or hardcode. Like i said, it's a silly little thing that just had my curiosity piqued
User is offlineProfile CardPM
+Quote Post

DeCompile
RE: Get Streamwriter Destination
13 Oct, 2008 - 07:35 PM
Post #9

D.I.C Head
**

Joined: 20 Jul, 2008
Posts: 180



Thanked: 6 times
My Contributions
It's certainly different. Considering they add that in the filestream, why wouldn't they put a similar in streamwriter..

Maybe that will have to be a bug report to Micros*ft.
User is offlineProfile CardPM
+Quote Post

magicmonkey
RE: Get Streamwriter Destination
14 Oct, 2008 - 08:23 AM
Post #10

D.I.C Regular
***

Joined: 12 Sep, 2008
Posts: 413



Thanked: 68 times
My Contributions
Because a streamwriter can write to any type of stream, a memorystream would not have a filename.
User is offlineProfile CardPM
+Quote Post

Damage
RE: Get Streamwriter Destination
14 Oct, 2008 - 11:55 AM
Post #11

D.I.C Addict
Group Icon

Joined: 5 Jun, 2008
Posts: 738



Thanked: 7 times
Dream Kudos: 75
My Contributions
oh, huh. Well i guess that answers that that one smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 03:34AM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month