I have this C# code:
void Main()
string extractPath = @C:\Test;

public void CleanExtractPath(string path)
if (Directory.Exists(path))
var recursive = true;
Directory.Delete(path, recursive);

On first run with Premium v5.26.01 this works.
On successive runs it fails on Directory.Delete.

If I cancel all threads with Ctrl-Shift-F5, it will again run.

Is it just something I'm doing wrong or is it a bug with LinqPad?


  • This is by-design. As you set the current directory to the newly created directory, it will be 'locked' and cannot be deleted.

    An equivalent in a command line window would be:
    C:\>md Test

    C:\>rd Test

    C:\>md Test

    C:\>cd Test

    C:\Test>rd C:\Test
    The process cannot access the file because it is being used by another process.
  • Also, when you change the current directory, the change will persist for next time you run the query. But when you press Ctrl+Shift+F5, it kills the query process, so it's like running it for the first time again.
  • Brilliant! Thank you.
  • edited March 9
    Thanks a lot! I thought I need a consultant to solve this problem but this is great that I have found the solution
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!