I’m trying to save a PDF file uploaded from the file uploader control in to a temporary location and read content from the saved file, but I’m getting error “The process cannot access the file because it is being used by another process.”
if (File.Exists(fullPath))
{
File.Delete(fullPath);
}
File.Create(fullPath).Close();
PDFParser pdfParser = new PDFParser();
String result = pdfParser.ExtractText(fullPath); //error is from here because the file is still in use with this line of code File.Create(fullPath).Close();
PDFParser logic is from here
How can I resolve this issue as I need to first store the PDF in a temporary location in order to access the full path from where it is uploaded as the browser gives a fake path and parse the saved file using PDFParser logic.