Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

using the "using()" statement with StreamReader/Writer

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    using the "using()" statement with StreamReader/Writer

    Is it "wise" to use the "using()" statement while reading, and writing to the file system in NT? I actually read the file in without using() because it's a one time shot in the OnStartUp() method and I "sr.Close()" the file when it's done, but when writing I have a:
    using(StreamWriter sw = new StreamWriter([file]))
    {
    sw.WriteLine("blah");
    }

    Each time a tick comes in. Is that too much overhead? Is there a more effiicient way? I'm experimenting because I've been getting "cannot access [file], it is being used by another process" (something similar) when trying to switch back and forth between diff. instruments/time frames in same chart window. This happens on and off, and I haven't figured out *exactly* which moves create that error. I'm assuming the write is staying open while the read is trying to access, hence the using() approach.

    #2
    Unfortunately this level of C# is beyond what we can offer support for. Hopefully a community member would have some ideas for you.

    All I can reference you to is how the StreamReader and StreamWriter are used in our reference samples here:

    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Josh,

      Could you have StreamWriter added to the F1 help? Maybe just me, but I cant locate anything there on it.

      Jon

      Comment


        #4
        Correct Jon, this is not in the helpguide, but in the list of educational resources we offer on NinjaScript on the forums here as well - http://www.ninjatrader.com/support/f...splay.php?f=29

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by sjsj2732, 03-23-2026, 04:31 AM
        0 responses
        42 views
        0 likes
        Last Post sjsj2732  
        Started by NullPointStrategies, 03-13-2026, 05:17 AM
        0 responses
        294 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        290 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        135 views
        1 like
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        98 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Working...
        X