"The given path's format is not supported".
using System;
using System.IO;
using System.Windows.Forms;
namespace WebcamCaptureRenamerGUI
{
public partial class Form1 : Form
{
FileSystemWatcher dir;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
dir = new FileSystemWatcher();
dir.IncludeSubdirectories = false;
dir.Path = "C:\Users\brendon\Desktop\Test";
dir.Filter = "*.*";
dir.Created += new FileSystemEventHandler(FileCreated);
dir.EnableRaisingEvents = true;
}
protected void FileCreated(object sender, FileSystemEventArgs e)
{
FileInfo info = new FileInfo(e.FullPath);
String fileExtension = info.Name.Split('.')[1];
String[] time = info.CreationTime.ToString().Split(' ');
String creationTime = String.Format("{0}_{1}", time[0].Replace('/','-'), time[1]);
String newFile = String.Format("{0}.{1}", creationTime, fileExtension);
newFile = Path.Combine(info.DirectoryName, newFile);
MessageBox.Show(String.Format("{0} {1}", e.FullPath, newFile));
try
{
info.MoveTo(newFile);
}
catch (Exception error)
{
MessageBox.Show(error.Message);
}
}
}
}
Any Ideas where I am going wrong?

New Topic/Question
Reply




MultiQuote






|