Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by judysamnt7, 03-13-2023, 09:11 AM
        4 responses
        59 views
        0 likes
        Last Post DynamicTest  
        Started by ScottWalsh, Today, 06:52 PM
        4 responses
        36 views
        0 likes
        Last Post ScottWalsh  
        Started by olisav57, Today, 07:39 PM
        0 responses
        7 views
        0 likes
        Last Post olisav57  
        Started by trilliantrader, Today, 03:01 PM
        2 responses
        21 views
        0 likes
        Last Post helpwanted  
        Started by cre8able, Today, 07:24 PM
        0 responses
        10 views
        0 likes
        Last Post cre8able  
        Working...
        X