[Closed] How to clear cache with maxscript?
I create a simple web browser in maxscript , but when i change html file in server , html file in cilent computer not update , is there a simple way to clean cache in maxscript ?
well… How you created a web browser with Max? dotnet? so you can also delete the cache that way.
i don’t have time to check it specially for IE11 but the general method could be as:
global InternetCacheAssembly =
(
local source = ""
source += "using System;\n"
source += "using System.IO;\n"
source += "\n"
source += "public class InternetCache\n"
source += "{\n"
source += " public static string GetFolderPath()\n"
source += " {\n"
source += " return Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);\n"
source += " }\n"
source += " public static void Delete()\n"
source += " {\n"
source += " string path = GetFolderPath();\n"
source += " DirectoryInfo di = new DirectoryInfo(path);\n"
source += " foreach (FileInfo file in di.GetFiles())\n"
source += " {\n"
source += " file.Delete();\n"
source += " }\n"
source += " foreach (DirectoryInfo dir in di.GetDirectories())\n"
source += " {\n"
source += " dir.Delete(true);\n"
source += " }\n"
source += " }\n"
source += "}\n"
csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"
compilerParams.ReferencedAssemblies.Add("System.dll");
compilerParams.GenerateInMemory = true
compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(source)
compilerResults.CompiledAssembly
)
/*
InternetCache_cl = dotnetclass (InternetCacheAssembly.GetTypes())[1]
InternetCache_cl.GetFolderPath()
InternetCache_cl.Delete()
*/
i’m pretty sure there is a way to write the same using pure mxs and dotnet (just catch the idea)
i changed a little bit
InternetCache_cl = dotnetclass (InternetCacheAssembly.GetTypes())[1]
fileClass = dotNetClass “System.IO.Directory”
cache_path = InternetCache_cl.GetFolderPath()
searchSubDirs=(dotnetClass “System.IO.SearchOption”)
theFile=(fileClass.GetFiles cache_path “*.htm” searchSubDirs.AllDirectories)
for i = 1 to theFile.count do
(
try(deletefile theFile[i])catch()
)