c# - How to save file in Temporary Internet Files -


i want create cache files .js after windows initialization console application, i'm not able. code:

var tempfilepath = environment.getfolderpath(environment.specialfolder.internetcache); var filepath = path.combine(tempfilepath,"my.js");  var requestfile = (httpwebrequest)httpwebrequest.create("http://my-address/my.js"); requestfile.method = "get";  var httpresponse = (httpwebresponse)(requestfile.getresponse());  using (var responsestream = httpresponse.getresponsestream()) {     var myjs = new streamreader(responsestream).readtoend();      file.writealltext(filepath, myjs); } 

so, in order write files directly ie cache folder, you'll need use wininet.dll

you can use createurlcacheentry , commiturlcacheentryw functions inject files cache.

https://msdn.microsoft.com/en-us/library/windows/desktop/ff384270(v=vs.85).aspx

https://msdn.microsoft.com/en-us/library/ms235282.aspx


Comments