> For the complete documentation index, see [llms.txt](https://aptivi.gitbook.io/aptivi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://aptivi.gitbook.io/aptivi/nitrocid-ks-v0.2.1-rolling-manual/advanced-and-power-users/kernel-modifications/analyzer-diagnostics/files-nks0015.md).

# Files - NKS0015

Use Moving.MoveFileOrDir()

This analyzer provides the following strings:

<table><thead><tr><th width="174">Context</th><th>String</th></tr></thead><tbody><tr><td>Error List</td><td>Caller uses <code>File.Move</code> instead of <code>FilesystemTools.MoveFileOrDir()</code></td></tr><tr><td>Suggestion Box</td><td>Use <code>FilesystemTools.MoveFileOrDir()</code> instead of <code>File.Move</code></td></tr><tr><td>Description</td><td><code>FilesystemTools.MoveFileOrDir()</code> neutralizes the provided path to its absolute correct path, while <code>File.Move</code> operates at the executable directory (<code>Environment.CurrentDirectory</code>), which may not be what you want.</td></tr></tbody></table>

***

## <mark style="color:$primary;">Extended Description</mark>

This code analyzer detects the usage of `Move` from the standard `File` class found in the `System.IO` namespace.

Using `File.Move()`, path neutralization doesn't take place to ensure that we have the correct absolute path. This causes some of the filesystem operations to operate on files, which are located in the wrong place, and, therefore, errors throw about a target not being found.

A solution to this problem was made with `MoveFileOrDir()`, because it takes care of the absolute paths and tries to reduce this kind of error caused by passing relative directories to the arguments.

***

## <mark style="color:$primary;">Analysis Comparison</mark>

To get a brief insight about how this analyzer works, compare the two code blocks shown to you below:

### <mark style="color:$primary;">Before the fix</mark>

<pre class="language-csharp" data-title="Somewhere in your mod code..." data-line-numbers><code class="lang-csharp">public static void MyFunction()
{
<strong>    File.Move("test.txt", PathsManagement.AppDataPath);
</strong>}
</code></pre>

### <mark style="color:$primary;">After the fix</mark>

<pre class="language-csharp" data-title="Somewhere in your mod code..." data-line-numbers><code class="lang-csharp">public static void MyFunction()
{
<strong>    FilesystemTools.MoveFileOrDir("test.txt", PathsManagement.AppDataPath);
</strong>}
</code></pre>
