首页 > 解决方案 > 如何删除或关闭文件。如果它正在另一个进程中使用?

问题描述

 case "Trend":
                    try
                    {
                        if (File.Exists(path + @"Trend.jpg"))
                        {
                            PublicClass.trendimage = "";
                            File.Delete(path + @"Trend.jpg");
                        }
                        else
                        { }

                        objImage.SaveImage(path + @"Trend.jpg");
                        PublicClass.trendimage = path + @"Trend.jpg";
                    }

当我尝试使用代码删除文件时。它告诉我你不能删除它正在另一个进程中使用的文件。所以,请告诉我如何删除文件。

标签: .netvisual-studioc#-4.0

解决方案


推荐阅读