VB.NET throws System.IO.IOException unsupported when trying to overwrite file

0

I have this code in my application:

My.Computer.FileSystem.CopyFile("D:\Temp\Origin.log", "D:\Temp\Destination.log", True)

This code used to work fine until 1 or 2 months ago.

The last couple of months it fails to execute and it throws a 'System.IO.IOException' in mscorlib.dll "Unsupported" when the destination files exists.

My target framework is 4.7.2

I tried to change target framework to 4.6.2 in case an update of NET framework broke it, but still I have the same issue.

Right now I had to temporarily bypass the problem like this:

If My.Computer.FileSystem.FileExists("D:\Temp\Destination.log") Then
      My.Computer.FileSystem.DeleteFile("D:\Temp\Destination.log", FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently)
End If
My.Computer.FileSystem.CopyFile("D:\Temp\Origin.log", "D:\Temp\Destination.log", True)

While the above code works, it defeats the purpose of having an overwrite overload (which is still supported in 4.7.2 AFAIK)

Also it means I have to change it in far too many places inside my application code.

Does anyone knows why my original code stopped working, or better yet, how to fix it ?

Edit: Exception Stack:

System.IO.IOException
  HResult=0x80070032
  Message=The request is not supported.

  Source=mscorlib
  StackTrace:
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost)
   at Microsoft.VisualBasic.FileIO.FileSystem.CopyOrMoveFile(CopyOrMove operation, String sourceFileName, String destinationFileName, Boolean overwrite, UIOptionInternal showUI, UICancelOption onUserCancel)
   at Microsoft.VisualBasic.MyServices.FileSystemProxy.CopyFile(String sourceFileName, String destinationFileName, Boolean overwrite)
   at KT_Scan_Docs_Manager.Frm_Main.CreateFilelist(Int32 Meleti) in C:\Users\GTsag\Dropbox\Visual Studio\KT2-14 Scan Docs Manager\KT2-14 Scan Docs Manager\frm_Main.vb:line 2880
   at KT_Scan_Docs_Manager.Frm_Main.Bt_KT214CreateFileList_Click(Object sender, EventArgs e) in C:\Users\GTsag\Dropbox\Visual Studio\KT2-14 Scan Docs Manager\KT2-14 Scan Docs Manager\frm_Main.vb:line 148
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
   at KT_Scan_Docs_Manager.My.MyApplication.Main(String[] Args) in :line 81
vb.net
asked on Stack Overflow Feb 17, 2020 by PhantomDj • edited Feb 18, 2020 by PhantomDj

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0