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.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    576 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    334 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    553 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    551 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X