<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="VB6Parse Library Reference - name - File Operations">
<title>name - File Operations - VB6Parse Library Reference</title>
<link rel="stylesheet" href="../../../assets/css/style.css">
<link rel="stylesheet" href="../../../assets/css/docs-style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css">
<script src="../../../assets/js/theme-switcher.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/vbnet.min.js"></script>
<script>hljs.highlightAll();</script>
</head>
<body>
<header class="docs-header">
<div class="container">
<h1><a href="../../../index.html">VB6Parse</a> / <a href="../../../library/index.html">Library</a> / <a href="../../../library/statements/file_operations/index.html">File Operations</a> / name</h1>
<p class="tagline">VB6 Library Reference</p>
</div>
</header>
<nav class="docs-nav">
<div class="container">
<a href="../../../index.html">Home</a>
<a href="../../../library/index.html">Library Reference</a>
<a href="../../../documentation.html">Documentation</a>
<a href="https://docs.rs/vb6parse" target="_blank">API Docs</a>
<a href="https://github.com/scriptandcompile/vb6parse" target="_blank">GitHub</a>
<button id="theme-toggle" class="theme-toggle" aria-label="Toggle theme">
<span class="theme-icon">🌙</span>
</button>
</div>
</nav>
<main class="container">
<article class="library-item">
<h1 id="name-statement">Name Statement</h1>
<p>Renames a disk file, directory, or folder.</p>
<h2 id="syntax">Syntax</h2>
<pre><code class="language-vbnet">Name oldpathname As newpathname</code></pre>
<ul>
<li><code>oldpathname</code>: Required. String expression that specifies the existing file name and location. May include directory or folder, and drive.</li>
<li><code>newpathname</code>: Required. String expression that specifies the new file name and location. May include directory or folder, and drive.
Cannot specify a different drive from the one specified in <code>oldpathname</code>.</li>
</ul>
<h2 id="remarks">Remarks</h2>
<ul>
<li>The <code>Name</code> statement renames a file and moves it to a different directory or folder, if necessary</li>
<li><code>Name</code> can move a file across directories or folders, but both <code>oldpathname</code> and <code>newpathname</code> must be on the same drive</li>
<li>Using <code>Name</code> on an open file produces an error. You must close an open file before renaming it</li>
<li><code>Name</code> arguments can include relative or absolute paths</li>
<li>The <code>Name</code> statement can also rename directories or folders</li>
<li>If <code>newpathname</code> already exists, an error occurs</li>
<li>Wildcard characters (* and ?) are not allowed in either <code>oldpathname</code> or <code>newpathname</code></li>
</ul>
<h2 id="examples">Examples</h2>
<pre><code class="language-vbnet">' Rename a file
Name "OLDFILE.TXT" As "NEWFILE.TXT"
' Move and rename a file
Name "C:\Data\Report.doc" As "C:\Archive\OldReport.doc"
' Rename a directory
Name "C:\OldFolder" As "C:\NewFolder"
' Move file to different directory (same drive)
Name "C:\Temp\Test.dat" As "C:\Data\Test.dat"
' Using variables
Dim oldName As String, newName As String
oldName = "File1.txt"
newName = "File2.txt"
Name oldName As newName</code></pre>
<h2 id="reference">Reference</h2>
<p><a href="https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/name-statement">Name Statement - Microsoft Docs</a></p>
</article>
<div style="margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--border-color);">
<p>
<a href="index.html">← Back to File Operations</a> |
<a href="../index.html">View all statements</a>
</p>
</div>
</main>
<footer>
<div class="container">
<p>© 2024-2026 VB6Parse Contributors. Licensed under the MIT License.</p>
</div>
</footer>
</body>
</html>