private void RenameFile(ImageInfo info) { Image image = System.Drawing.Image.FromFile(info.Path); string meta = _encoding.GetString(image.PropertyItems[15].Value).TrimEnd('\0'); image.Dispose(); string[] tokens = meta.Split(' '); string date = tokens[0].Replace(":", string.Empty); string time = tokens[1].Replace(":", string.Empty); System.IO.DirectoryInfo parentDirectory = System.IO.Directory.GetParent(info.Path); string parentDirName = parentDirectory.Name; parentDirName = parentDirName.Replace(" ", "_"); parentDirName = parentDirName.ToLower(); string fileName = parentDirName + "_" + date + "_" + time + ".jpg"; string newFilePath = System.IO.Path.Combine(parentDirectory.FullName, fileName); int i = 2; while (System.IO.File.Exists(newFilePath)) { fileName = parentDirName + "_" + date + "_" + time + "_" + i + ".jpg"; newFilePath = System.IO.Path.Combine(parentDirectory.FullName, fileName); } System.IO.File.Move(info.Path, newFilePath); }
public void LoadImage(ImageInfo imageInfo) { _pictureBox.SuspendDrawing(); _currentImageInfo = imageInfo; _pictureBox.Image = System.Drawing.Image.FromFile(_currentImageInfo.Path); CheckPictureBoxSize(); this.Text = _currentImageInfo.Path; _pictureBox.ResumeDrawing(); }
public void UnloadImage() { _currentImageInfo = null; _pictureBox.Image = null; }