Can rename file provider items.
This commit is contained in:
parent
7e35924fb6
commit
38d55cb2f2
1 changed files with 14 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue