2011-11-24 42 views
1

我在windows application.i中使用webbrowser控件查看webbrowser控件中的url内容。这里的url内容值存储在用户机器的临时网络文件中。通过“C#”清除临时Internet文件

当我点击我的窗体中的关闭按钮时,我正在以编程方式删除临时Internet文件。它工作正常。 但在删除期间,“消息框出现并说删除临时Internet文件”。

这里我不想在删除过程中显示该对话框。下面的 是删除用户机器的临时文件的代码。

如何处理这个..

void DeleteBrowserTempFile() 
    { 
     string args = ""; 
     args = ("InetCpl.cpl,ClearMyTracksByProcess 8"); 
     System.Diagnostics.Process process = null; 
     System.Diagnostics.ProcessStartInfo processStartInfo; 
     processStartInfo = new System.Diagnostics.ProcessStartInfo(); 
     processStartInfo.FileName = Environment.GetFolderPath(Environment.SpecialFolder.System) + "\\Rundll32.exe"; 
     if ((System.Environment.OSVersion.Version.Major >= 6)) 
     { 
      // Windows Vista or higher 
      processStartInfo.Verb = "runas"; 
     } 
     processStartInfo.Arguments = args; 
     processStartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; 
     processStartInfo.UseShellExecute = true; 
     try 
     { 
      process = System.Diagnostics.Process.Start(processStartInfo); 
     } 
     catch (Exception ex) 
     { 
      Utilities.WriteErrorLog(ex); 
     } 
     finally 
     { 
      if (!(process == null)) 
      { 
       process.Dispose(); 
      } 
     } 
    } 

是否有任何其他的方式来实现这个.. 需要UR举例建议

问候

Anbuselvan

+0

在IE中有设置可以在退出时删除临时文件。不知道你是否可以从这里访问它... –

回答