Can rename file provider items.

This commit is contained in:
larsbrubaker 2015-07-28 14:21:17 -07:00
parent 7e35924fb6
commit 38d55cb2f2

View file

@ -86,7 +86,20 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider
public override void RenameItem(int itemIndexToRename, string newName)
{
throw new NotImplementedException();
string sourceFile = Path.Combine(rootPath, currentDirectoryFiles[itemIndexToRename]);
if (File.Exists(sourceFile))
{
string destFile = Path.Combine(Path.GetDirectoryName(sourceFile), newName);
File.Move(sourceFile, destFile);
Stopwatch time = Stopwatch.StartNew();
// Wait for up to some amount of time for the directory to be gone.
while (File.Exists(destFile)
&& time.ElapsedMilliseconds < 100)
{
Thread.Sleep(1); // make sure we are not eating all the cpu time.
}
GetFilesAndCollectionsInCurrentDirectory();
}
}
public override int ItemCount