I have a number of published PDFs on the file system which I am required to update and save again on the File System itself.
So far I am able to update the PDF by creating a temp file. The original published PDF has to be replaced by the temp file, which is not possible as Tridion is preventing deletion of the published PDF.
How can I unpublish the PDF, and then replace it with the temp file?
Is it possible to unpublish a PDF from the file system at all?
This is the code I am using to replace old file and delete temp file. It is working fine in a local environment, but in Tridion it is not able to delete or make any changes to the published original PDF.
private void GetFileNames(string PDfpath, string filter)
{
string FullFilePath = string.Empty;
string[] files = Directory.GetFiles(PDfpath, filter);
for (int i = 0; i < files.Length; i++)
{
files[i] = Path.GetFileName(files[i]);
if (files[i] == "temp.pdf")
{
FullFilePath = PDfpath + "\\" + files[i];
File.Copy(PDfpath + "\\" + "temp.pdf", PDfpath + "\\" + "old.pdf", true);
File.Delete(FullFilePath);
}
}
}
Please advise..