My thread cannot delete PDF files. When I debug this solution, the file is deleting. In service mode, it is not deleting.
This is my sample code:
Thread Worker = new Thread(new ThreadStart(Start)); //Main Function
Worker.Start();
public void Start()
{
string text=PDFToText(@"C:\1.pdf");
File.Delete(@"C:\1.pdf");
}
private string PDFToText(string filename) // My PDF reader function
{
PDDocument doc = PDDocument.load(filename);
PDFTextStripper stripper = new PDFTextStripper();
string text = stripper.getText(doc);
doc.close();
return text;
}
Where is the problem?