Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Used by another process?

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

    Used by another process?

    Hi,

    I'm getting a log error that reads "The process cannot access the file because it is being used by another process". I don't see how this could be the case, my strategy is running only on one instrument. The following code causes the error:

    string path = Cbi.Core.UserDataDir.ToString() + "17Closes.inp";
    string path2 = Cbi.Core.UserDataDir.ToString() + "TEMP17.txt";
    //create file info
    FileInfo fi1 = new FileInfo(path);
    FileInfo fInfo = new FileInfo(path);
    // replace the file.
    fInfo.Replace(path, path2, false);


    if (!fi1.Exists)
    {
    //Create a file to write to.
    using (StreamWriter sw = fi1.CreateText())
    {
    //Do stuff
    }
    }


    I'm simply trying to delete a file before I create a new one again because I don't want to append to an existing file.

    #2
    You will get error as you open a file multiple times. Please consults the MS docs on files handling for details. This is beyond teh scoep of what we can provide support for.
    DierkNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by vantojo, Today, 09:32 AM
    0 responses
    4 views
    0 likes
    Last Post vantojo
    by vantojo
     
    Started by FelipeRXP, Today, 08:40 AM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by petedian, Today, 08:44 AM
    0 responses
    12 views
    0 likes
    Last Post petedian  
    Started by J0shTrader, Yesterday, 12:29 PM
    1 response
    2 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Started by bc24fl, Today, 08:07 AM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Working...
    X