ale na moju smolu, neviem vymazat bitmapu po konverzii, lebo mi vyskoci exception, file in use.
nejake napady ako to ochcat?
Kód: Vybrať všetko
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace bmp2png_converter
{
class Convert
{
static void Main(string[] args)
{
DirectoryInfo d = new DirectoryInfo(@"D:\test\");
FileInfo[] infos = d.GetFiles("*.bmp");
foreach (FileInfo f in infos)
{
// Load the image in BMP format.
System.Drawing.Image image1 = System.Drawing.Image.FromFile(f.FullName);
// Save the image in PNG format.
image1.Save(@"D:\test\" + f.Name.Replace("bmp", "png"), System.Drawing.Imaging.ImageFormat.Png);
// Delete BMP image.
File.Delete(f.FullName); //exception - file in use.
}
}
}
}