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 Spiderbird, Today, 12:15 PM
        2 responses
        8 views
        0 likes
        Last Post Spiderbird  
        Started by WHICKED, Today, 12:45 PM
        0 responses
        3 views
        0 likes
        Last Post WHICKED
        by WHICKED
         
        Started by FrazMann, Today, 11:21 AM
        2 responses
        6 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Started by rjbtrade1, 11-30-2023, 04:38 PM
        2 responses
        80 views
        0 likes
        Last Post DavidHP
        by DavidHP
         
        Started by lorem, Yesterday, 09:18 AM
        5 responses
        18 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X