Results 1 to 2 of 2

Thread: reading a file

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    183

    reading a file

    hummm I get a strange result when I try and read a file and put its contents in a textbox... here is the code:

    <code>
    string strPath= "C:\\test.log";

    FileStream logFile = new FileStream(strPath, FileMode.Open);
    int len =(int)logFile.Length;
    byte [] logdata = new byte [len];

    logFile.Read(logdata,0,len);

    txtLogFile.Text = logdata.ToString();
    </code>

    for some reason the output (regardless of the file contents) is "System.Byte[]"

    Any ideas? or know the right way to do this?

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    What kind of data is in test.log?

    Anyway try this.

    Code:
    string strPath= "test.log";
    
    FileStream logFile = new FileStream(strPath, FileMode.Open);
    int len =(int)logFile.Length;
    byte [] logdata = new byte [len];
    
    logFile.Read(logdata,0,len);
    
    textBox1.Text = Convert.ToBase64String(logdata);
    Dont gain the world and lose your soul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width