TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ali G
NA
51
38.7k
After Reaching Exif Data I can't Rename Them
Sep 28 2013 11:47 AM
Hen I reach the jpeg's date and time. I can't change that file's name. It gives exception. How can I solve this problem. Files are behaving like "in use" and I can't change their names.
My codes are here:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging; //YENI
using System.IO; //YENI
namespace PhotoRenamer2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
DialogResult result = folderBrowserDialog1.ShowDialog();
string pathname = @folderBrowserDialog1.SelectedPath;
label2.Text = pathname;
FileInfo[] files = new DirectoryInfo(pathname).GetFiles("*.JPG");
for (int i = 0; i < files.Length; i++)
{
string DateAndTimePictureTaken = string.Empty;
Image image = new Bitmap(@files[i].FullName);
foreach (PropertyItem propItem in image.PropertyItems)
{
if (propItem.Id == 0x0132)
{
DateAndTimePictureTaken = (new System.Text.ASCIIEncoding()).GetString(propItem.Value);
string Year = DateAndTimePictureTaken.Substring(0, 4);
label3.Text = Year;
string newFile = String.Format("{0}{1}.{2}", "a", (i + 1), "JPG");
string fullNewPath = files[i].DirectoryName;
string newFileWithPath = Path.Combine(fullNewPath, newFile);
label2.Text = files[i].FullName;
label3.Text = newFileWithPath;
File.Move(files[i].FullName, newFileWithPath);
break;
}
}
}
}
}
}
Reply
Answers (
2
)
Problem in adding controls dynamically in user control
ListView SortOrder Ascending changing textbox values