When using the FileSystem.Rename
function in VB.Net Core, warning CA1416 pops up, saying this function is only supported on Windows. However, none of my research has gleaned what alternative there is for other OSes.
I was wondering what a workaround that works on all platforms might look like.
CodePudding user response:
You shouldn't be using VB6 holdovers like that in the first place, whether on Windows or not, .NET Core or .NET Framework. Pretty much any function that is a member of a module in the Microsoft.VisualBasic
namespace should be avoided unless it provides specific value over the alternative(s).
At the very least, if you're going to use something VB-specific then use My.Computer.FileSystem.RenameFile
. Even that may be Windows-specific though, because I think that it uses the Windows shell.
If you stick to straight-up, standard .NET stuff then you'd be using the System.IO
namespace and, in this case, File.Move
.