﻿<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <Title> Renaming a file </Title>
            <Description> Expansion snippet for renaming a file. </Description>
            <Author>Microsoft Corporation</Author>
            <SnippetTypes>          
                <SnippetType> Expansion </SnippetType>
            </SnippetTypes>
        </Header>
        <Snippet>
            <Declarations>
                <Literal>
                    <ID> OldFileName </ID>
                    <Default> strOldFileName </Default>
                    <ToolTip> Variable to hold the existing file name </ToolTip>
                </Literal>
        <Literal>
                    <ID> NewFileName </ID>
                    <Default> strNewFileName </Default>
                    <ToolTip> Variable to hold the new folder name. </ToolTip>
                </Literal>
            </Declarations>
            <Code Language="vjsharp" Format="CData"><![CDATA[
boolean flStatus = false; //variable is set to true if renaming of file was successful else false

//Check if the old file name and new file names are not null and not blank
if (($OldFileName$ != null && $OldFileName$.length() > 0) &&
    ($NewFileName$ != null && $NewFileName$.length() > 0))
{
    java.io.File objOldFile = new java.io.File($OldFileName$);
    if (objOldFile.isFile())
    {
      java.io.File objNewFile = new java.io.File($NewFileName$);
      flStatus = objOldFile.renameTo(objNewFile);
    }
}
$selected$ $end$
]]>
</Code>
        </Snippet>
    </CodeSnippet>
</CodeSnippets>
