Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

C#


  • Please log in to reply

#1
Tony#

Tony#

    New Member

  • Member
  • Pip
  • 2 posts
I have a class with a GetCSVRow() method, that returns a string. I need to iterate through an ArrayList of member objects, invoking the GetCSVRow() method, and write the returned strings to a text file. I know how to do every element of this task, except the output to a text file.

I am familiar primarily with VB and Java, and I have used C in the past, but I am now learning C#. In VB, I would simply do a FileOpen(), and use PrintLine().

The only thing I have found so far is to create a FileInfo object, create a FileStream object using the FileInfo object's OpenWrite() method, and invoke the FileStream's Write method, to write an array of Bytes.

Is this the only way? If so, how do I turn a string into a byte[]?
  • 0

Advertisements


#2
destin

destin

    Member

  • Member
  • PipPip
  • 53 posts

If so, how do I turn a string into a byte[]?

Google: string to byte array c#
  • 0

#3
Tony#

Tony#

    New Member

  • Topic Starter
  • Member
  • Pip
  • 2 posts
Thanks Destin. I hadn't yet searched Google for this conversion, because I was hoping for a simpler way to write a text file. Using Google, I found that the StreamWriter class is instantiated using the CreateText method of the FileInfo object, and offers the Write method I was looking for.

That's good stuff though, thanks!
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP