azuretempdir

deleting existing files from temp directory in Azure


We are using the following to write a file to the temp direcotry in Azure webapp for almost a year:

      string tempName = Path.GetTempFileName();
      using (var tempFile = new FileStream(tempName, FileMode.Create))
      {
        await tempMemory.CopyToAsync(tempFile);
      }

We encounter a problem of IOException of file alreay exists in the temp file.

Is there any way deleting the files from that temp directory and not from code. we do not want to apply a new code version currently, but just to somehow delete the files from the temp directory.

we tried using the azure webapp console from the portal but it didn't delete them.


Solution

  • Restart the WebApp, it will clear the temp directory.