使用SwfDotNet时如何处理垃圾收集/免费资源

时间:2012-12-10 06:22:24

标签: asp.net c#-4.0 webforms

我能读出身高和高度。使用.swf文件&如果它不在指定的维度内,那么我必须从服务器删除该文件,不幸的是它不断产生错误,因为我无法释放资源,我不确定我还有什么其他资源可以免费。

Tutorial link

该进程无法访问文件'C:\ PROJECTS \ xyz \ images \ banners \ file.swf',因为它正由另一个进程使用。

/* Not using below case as i not able to dispose the swfReader object which can result in unnecessary memory*/

   // Create a swf stream reader
   SwfReader swfReader = new SwfReader(path);
   // Read the completed swf file
   Swf swf = swfReader.ReadSwf();
   // Read only headers of file to optimize read speed
   //Swf swf = swfReader.ReadSwfHeader();
   int swfHeight = swf.Header.Height;
   int swfWidth = swf.Header.Width;
   swfReader.Close();
   if ((swfHeight > int.Parse(hdnBannerHeight.Value)) || (swfWidth > int.Parse(hdnBannerWidth.Value)))
   {
       lblImageUploadMessage1.Text = "File cant be upload as it has invalid dimensions";
       lblImageUploadMessage1.CssClass = "lblErrorMSG";
       Session["bannerImage"] = null;
       if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); }
   }

以上代码生成与其他进程使用的文件相关,我无法使用IDispose方法,所以我不知道如何解决此问题。我只是使用FileUpload服务器控件在asp.net Web表单上传文件。

0 个答案:

没有答案