Results 1 to 11 of 11

Thread: Read file into richtextbox *[resolved]*

  1. #1

    Thread Starter
    Hyperactive Member RealNickyDude's Avatar
    Join Date
    Nov 2002
    Location
    Watching you through the hidden camera :o
    Posts
    435

    Thumbs up Read file into richtextbox *[resolved]*

    How? I've searched the forum and came across this:

    VB Code:
    1. Dim fs As FileStream = New FileStream(Application.StartupPath & "\snippets.txt", IO.FileMode.Open)
    2. Dim sw As New StreamWriter(fs)
    3. sw.Write(rtbcodewindow.Text)
    4. sw.Close()
    5. fs.Close()

    but nothing seems to happen!

    I have a toolbar and pressing various buttons will load an associated rtf file, plain and simple, but how? I need the exact code as I can get bugger all to work!

    Last edited by RealNickyDude; Dec 31st, 2002 at 12:01 PM.
    [vbcode]
    On Error GoTo Hell
    [/vbcode]:¬) Nicky : Why not try VBCodebook.NET.

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I'm sure ,this solves your problem .
    http://abstractvb.com/code.asp?F=11&P=1&A=969

    add this to your VB.NET Book

  3. #3

    Thread Starter
    Hyperactive Member RealNickyDude's Avatar
    Join Date
    Nov 2002
    Location
    Watching you through the hidden camera :o
    Posts
    435
    I've taken this line from it pirate:

    VB Code:
    1. rtbcodewindow.LoadFile(Application.StartupPath & "\forms.rtf", RichTextBoxStreamType.RichText)
    Hoping that will do it (as they are set files, not chosen by the user) but i'm getting this error:

    System.IO.FileNotFoundException' occurred in mscorlib.dll



    All i want is to load a specific file into a richtextbox, no filters, no user dialog boxes, no line-splitting, just a straight forward "load this rtf file into this rtb."
    [vbcode]
    On Error GoTo Hell
    [/vbcode]:¬) Nicky : Why not try VBCodebook.NET.

  4. #4

    Thread Starter
    Hyperactive Member RealNickyDude's Avatar
    Join Date
    Nov 2002
    Location
    Watching you through the hidden camera :o
    Posts
    435
    It's ok, its all sorted now, I didn't have the textfiles in the right place (doh!)
    [vbcode]
    On Error GoTo Hell
    [/vbcode]:¬) Nicky : Why not try VBCodebook.NET.

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    ,

  6. #6
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    ahem ahem ahem, so many people make this mistake, in vb6 and in vb.net
    when you use "Application.StartupPath" it sometimes returns the path without a "\" at the end, but NOT ALWAYS!
    If you run your app from the root directory in drive C for example, it is going to return "C:\", WITH a backslash.....
    so dont just use Application.StartupPath & "\"


    You could just use IO.Path.Combine (Application.StartupPath, "filename")


    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  7. #7
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Great tip MrPolite. I have never seen that before. Thanks

  8. #8
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by hellswraith
    Great tip MrPolite. I have never seen that before. Thanks
    hehe, same with app.path in vb6
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  9. #9

    Thread Starter
    Hyperactive Member RealNickyDude's Avatar
    Join Date
    Nov 2002
    Location
    Watching you through the hidden camera :o
    Posts
    435
    Originally posted by MrPolite
    ahem ahem ahem, so many people make this mistake, in vb6 and in vb.net
    when you use "Application.StartupPath" it sometimes returns the path without a "\" at the end, but NOT ALWAYS!
    If you run your app from the root directory in drive C for example, it is going to return "C:\", WITH a backslash.....
    so dont just use Application.StartupPath & "\"


    You could just use IO.Path.Combine (Application.StartupPath, "filename")


    Could you tell me exactly how Mr Polite? and thanks for the tip.

    Oh, and a Happy New Year to everyone!
    [vbcode]
    On Error GoTo Hell
    [/vbcode]:¬) Nicky : Why not try VBCodebook.NET.

  10. #10
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Happy new year!


    can I tell you how to do what? use that path.combine? hmm

    well you could do something like this:
    VB Code:
    1. Dim docPath As String = IO.Path.Combine(Application.StartupPath,"forms.rtf")
    2.  
    3. rtbcodewindow.LoadFile(docPath, RichTextBoxStreamType.RichText)

    btw I havent tested that code, hope it works
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  11. #11

    Thread Starter
    Hyperactive Member RealNickyDude's Avatar
    Join Date
    Nov 2002
    Location
    Watching you through the hidden camera :o
    Posts
    435
    Works a treat Mr Polite
    [vbcode]
    On Error GoTo Hell
    [/vbcode]:¬) Nicky : Why not try VBCodebook.NET.

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