I am making an application that shows some pdfs and has two accesses, one the user that views them and another the administrator that updates the pdf. The problem is that updating the files will give an error if another person is viewing them.
replace code.
var dlg = new OpenFileDialog { DefaultExt = ".pdf", Filter = "PDF documents (.pdf)|*.pdf" };
dlg.ShowDialog();
if (!string.IsNullOrEmpty(dlg.FileName))
{
try
{
string destino = red + listPdf[CurrentPdf];
if (File.Exists(destino))
{
File.Delete(destino);
File.Copy(dlg.FileName, destino);
}
else File.Copy(dlg.FileName, destino);
pdfViewer.LoadFile(destino);
}
catch (Exception ex){MessageBox.Show("Error \n" + ex.Message);}
}
upload code
pdfViewer.LoadFile(red + listPdf[CurrentPdf = 0]);