I know, and I am sorry for saying that. I noticed a bit too late (after 30 mins, which is the limit for editing posts). So I couldn`t change it.
I saw a bit later he added a sing "\" on the end of "TempDir".
Sorry ones again, really didnt see it.
But I do have another small problem.
I did the upper code which creates a temp folder in which will be saved files, retrieved from the database. But I want to delete these files and the best I could think of is to delete files in the next session (when user re-opens this app.). This code does this, but I have a problem, if there is one of these files still opened (the file uses another process).
How can I do the code for letting the user know, that if he want to run the application again , he has to close that file (if he opeded the file myFile.pdf, he has to close this file which is running in acrobat Reader )
if (System.IO.Directory.Exists(System.IO.Path.GetTempPath() + @"\MyTempDir"))
{
string[] files = Directory.GetFiles(System.IO.Path.GetTempPath() + @"\MyTempDir");
foreach (string file in files)
{
//HERE I AM MISSING AN ERROR MESSAGE!
File.Delete(file);
}
}
else
System.IO.Directory.CreateDirectory(System.IO.Path.GetTempPath() + @"\MyTempDir");
And it is a good idea of deleteing them on app close () event.
But still I can not delete file, if this is opened, righ? So, please for some help. And consider that I do not know which file, maybe there are more files opened.