private void CorrectPictureExtention(string PictureFile)
{
FileInfo FileData = My.Computer.FileSystem.GetFileInfo(PictureFile);
if (FileData.Exists == true) {
Bitmap PictureBitmap = null;
try {
PictureBitmap = Bitmap.FromFile(PictureFile);
} catch {
}
if (PictureBitmap != null) {
Dictionary GuidDictionary = new Dictionary();
GuidDictionary.Add("b96b3cab-0728-11d3-9d7b-0000f81ef32e", ".Bmp");
GuidDictionary.Add("b96b3cac-0728-11d3-9d7b-0000f81ef32e", ".Emf");
GuidDictionary.Add("b96b3cb0-0728-11d3-9d7b-0000f81ef32e", ".Gif");
GuidDictionary.Add("b96b3cb5-0728-11d3-9d7b-0000f81ef32e", ".Ico");
GuidDictionary.Add("b96b3cae-0728-11d3-9d7b-0000f81ef32e", ".Jpg");
GuidDictionary.Add("b96b3caf-0728-11d3-9d7b-0000f81ef32e", ".Png");
GuidDictionary.Add("b96b3cb1-0728-11d3-9d7b-0000f81ef32e", ".Tif");
GuidDictionary.Add("b96b3cad-0728-11d3-9d7b-0000f81ef32e", ".Wmf");
string ImageType = "";
GuidDictionary.TryGetValue(PictureBitmap.RawFormat.Guid.ToString, ImageType);
PictureBitmap.Dispose();
if (!string.IsNullOrEmpty(ImageType)) {
if (!string.IsNullOrEmpty(FileData.Extension)) {
if (FileData.Extension != ImageType) {
My.Computer.FileSystem.RenameFile(FileData.FullName, FileData.Name.Replace(FileData.Extension, "") + ImageType);
} else {
My.Computer.FileSystem.RenameFile(FileData.FullName, FileData.Name + ImageType);
}
}
}
}
}
}
Correct picture file extension
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment