Asp.net mvc 4 如何在ASP.NET中注册缓存按钮
我已经创建了缓存按钮来清除所有的.json文件。它在本地机器上运行良好。但当我上传到服务器时,缓存按钮不起作用 在服务器中上传后,当我单击clear cache按钮时,消息显示为缓存(.json文件)已被清除,但实际上所有.json文件仍保持原样 请帮我这个忙 下面是代码Asp.net mvc 4 如何在ASP.NET中注册缓存按钮,asp.net-mvc-4,c#-4.0,Asp.net Mvc 4,C# 4.0,我已经创建了缓存按钮来清除所有的.json文件。它在本地机器上运行良好。但当我上传到服务器时,缓存按钮不起作用 在服务器中上传后,当我单击clear cache按钮时,消息显示为缓存(.json文件)已被清除,但实际上所有.json文件仍保持原样 请帮我这个忙 下面是代码 #region Delete Cache Functions public bool FnDeleteCache(string directoryName) { try { var di = n
#region Delete Cache Functions
public bool FnDeleteCache(string directoryName)
{
try
{
var di = new DirectoryInfo(rootDirectory + directoryName);
di.Attributes &= ~FileAttributes.ReadOnly;
if (CacheAttribute() == true)
{
System.IO.DirectoryInfo directory = new System.IO.DirectoryInfo(rootDirectory + directoryName);
foreach (System.IO.FileInfo file in directory.GetFiles())
{
if (file.Name != null)
file.Delete();
}
return true;
}
}
catch
{
return false;
}
return false;
}
public bool FnDeleteCache(string directoryName, string FileName)
{
var di = new DirectoryInfo(rootDirectory + directoryName);
di.Attributes &= ~FileAttributes.ReadOnly;
if (CacheAttribute() == true)
{
System.IO.DirectoryInfo directory = new System.IO.DirectoryInfo(rootDirectory + directoryName);
foreach (System.IO.FileInfo file in directory.GetFiles())
{
if (file.Name.Contains(FileName))
{
file.Delete();
return true;
}
}
}
return false;
}
#endregion
谢谢。请发布一些代码。我们猜不出怎么了。一种可能是您的Web服务没有足够的权限删除文件。您好,先生,我已经发布了代码亲爱的xaviert,如何向Web服务添加删除.json文件的权限。请帮帮我。