0

I have a folder in the server and when I upload a file overwrite the existing file (means I save the file with the same name).

So when I open my website it should show me the new uploaded file but it shows the old file instead.

Is there any way to hard code directory refresh?

string folderPath = Server.MapPath("~/Resources/Slider/");
if (!Directory.Exists(folderPath))
{

    Directory.CreateDirectory(folderPath);
}

//Save the File to the Directory (Folder).
String extension = Path.GetExtension(FileUpload1.FileName);
FileUpload1.SaveAs(folderPath + "slide" + s4 + extension);

s4 = 1 or 2 or 3

This is how the directory that I want to refresh slider folder:

enter image description here

5377037
  • 9,493
  • 12
  • 43
  • 73
  • iam uploading images using FileUpload.SaveAs(FilePath); , i load it in Page_load method in asp.cs file , the problem is when i upload a file i have to manually refresh the folder which contains the file to get the new uploaded file – Dyar Ibrahim Aug 26 '17 at 12:10
  • Sounds like browser is caching the files. This is common for static content. Use fiddler or browser dev tools to verify this. If you don't even see request for the file it means the cached file has not expired yet. There are several ways you can deal with this, but if the files are uploaded and changed very often you may want to disable caching by using nocache header. – nothingisnecessary Aug 26 '17 at 14:22

0 Answers0