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.5k
Want to Rename All Files But Getting Exception
Sep 27 2013 7:16 PM
I have this code but it gives IOException. What is the problem with "File.Move(files[i].FullName, newFileWithPath);" line?
==================================================
private void button1_Click(object sender, System.EventArgs e)
{
DialogResult result = folderBrowserDialog1.ShowDialog();
if (result == DialogResult.OK)
{
string pathname = @folderBrowserDialog1.SelectedPath;
FileInfo[] files = new DirectoryInfo(pathname).GetFiles("*.JPG");
for (int i = 0; i < files.Length; i++)
{
string newFile = String.Format("{0}{1}.{2}", "A", (i+1), "JPG");
string fullNewPath = files[i].DirectoryName;
string newFileWithPath = Path.Combine(fullNewPath, newFile);
File.Move(files[i].FullName, newFileWithPath);
}
}
}
==================================================
Reply
Answers (
5
)
how to create a software define radio ?
Convert Windows Application in to Web application in ASP.NE