删除指定路径下指定格式的文件

private void deleteImgAndGoodsFile()
        {
            try
            {
                //删除temp文件夹下的 所有图片
                FileUtils.CreateDirectory(Application.StartupPath + "\\Temp\\");
                string[] arrImagesTemp = Directory.GetFiles(Application.StartupPath + "\\Temp\\", "*.*");
                foreach (string strTemp in arrImagesTemp)
                {
                    if (File.Exists(strTemp))
                    {
                        File.Delete(strTemp);
                    }
                }

                //删除 物品临时存储文件(二维码)
                FileUtils.CreateDirectory(Application.StartupPath + "//fp//");
                string[] arrGoodsFilesPath = Directory.GetFiles(Application.StartupPath + "//fp//", "goods_*.txt");
                foreach (string strGFP in arrGoodsFilesPath)
                {
                    if (File.Exists(strGFP))
                    {
                        File.Delete(strGFP);
                    }
                }

            }
            catch (Exception ex)
            {
        }

你可能感兴趣的:(Winform)