The atomicMove function seems to consistently throw an exception when using within an MSIX app on another disk (not C:).
How to reproduce:
- Have an MSIX app installed on another drive (not C:). (probably a java with the correct manifest for java apps?) (If you do not have another disk, just create a virtual drive under Settings, System, Storage, Disk & volumes, Create a virtual hard disk (VHD). It will mount as a new drive letter. Then you can move the msix app to it.)
- Open a Terminal or PowerShell and execute this to open a command prompt within the virtual MSIX environment (replace TODO with your app details)
Invoke-CommandInDesktopPackage -Command cmd.exe -PreventBreakaway -PackageFamilyName TODO_TODO -AppId TODO
Example in my case (you could just use the container of my app from the Microsoft Store as it is setup for java apps):
Invoke-CommandInDesktopPackage -Command cmd.exe -PreventBreakaway -PackageFamilyName HueEssentials.HueEssentials_yfdreesr38bg8 -AppId HueEssentials
- Now create a simple Kotlin project with this as main function:
import okio.FileSystem
import okio.Path.Companion.toOkioPath
import java.io.File
fun main() {
val a = File(System.getenv("APPDATA"), "testing/a.txt")
a.parentFile.mkdirs()
FileSystem.SYSTEM.write(a.toOkioPath()) {
writeUtf8("testing")
}
val b = File(System.getenv("APPDATA"), "testing/b.txt")
b.delete()
FileSystem.SYSTEM.atomicMove(a.toOkioPath(), b.toOkioPath())
}
-
Build a jar file for the above
-
After that, open the command prompt from step 2 and run the jar (java -jar ..)
-
On my machine I get this consistently:
C:\Users\Thomas\IdeaProjects\untitled1>java -jar build\libs\untitled1-fat-1.0-SNAPSHOT.jar
Exception in thread "main" java.nio.file.AtomicMoveNotSupportedException: C:\Users\Thomas\AppData\Roaming\testing\a.txt -> C:\Users\Thomas\AppData\Roaming\testing\b.txt: The system cannot move the file to a different disk drive
at java.base/sun.nio.fs.WindowsFileCopy.move(WindowsFileCopy.java:308)
at java.base/sun.nio.fs.WindowsFileSystemProvider.move(WindowsFileSystemProvider.java:287)
at java.base/java.nio.file.Files.move(Files.java:1319)
at okio.NioSystemFileSystem.atomicMove(NioSystemFileSystem.kt:78)
at org.example.MainKt.main(Main.kt:17)
at org.example.MainKt.main(Main.kt)
C:\Users\Thomas\IdeaProjects\untitled1>
It seems atomicMove fails even though it should be moved on one disk (I think). The MSIX app container I am running this in was installed on another drive, but Windows seems to be creating virtualized C disk paths. This is probably the cause of the issue.
Related:
The
atomicMovefunction seems to consistently throw an exception when using within an MSIX app on another disk (not C:).How to reproduce:
Example in my case (you could just use the container of my app from the Microsoft Store as it is setup for java apps):
Build a jar file for the above
After that, open the command prompt from step 2 and run the jar
(java -jar ..)On my machine I get this consistently:
It seems
atomicMovefails even though it should be moved on one disk (I think). The MSIX app container I am running this in was installed on another drive, but Windows seems to be creating virtualized C disk paths. This is probably the cause of the issue.Related: