尝试覆盖文件时,VB.NET引发System.IO.IOException不受支持
我的应用程序中有以下代码:尝试覆盖文件时,VB.NET引发System.IO.IOException不受支持,vb.net,Vb.net,我的应用程序中有以下代码: My.Computer.FileSystem.CopyFile(“D:\Temp\Origin.log”、“D:\Temp\Destination.log”,True) 在1或2个月前,此代码一直工作正常 在过去的几个月里,当目标文件存在时,它无法执行,并在mscorlib.dll中抛出一个“System.IO.IOException” 我的目标框架是4.7.2 我试图将目标框架更改为4.6.2,以防NET framework的更新破坏它,但仍然存在同样的问题 现在我
My.Computer.FileSystem.CopyFile(“D:\Temp\Origin.log”、“D:\Temp\Destination.log”,True)
在1或2个月前,此代码一直工作正常
在过去的几个月里,当目标文件存在时,它无法执行,并在mscorlib.dll中抛出一个“System.IO.IOException”
我的目标框架是4.7.2
我试图将目标框架更改为4.6.2,以防NET framework的更新破坏它,但仍然存在同样的问题
现在我不得不暂时绕过这样的问题:
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)
虽然上面的代码可以工作,但它无法实现覆盖重载的目的(4.7.2 AFAIK仍然支持覆盖重载)
这也意味着我必须在我的应用程序代码中的太多地方修改它
有人知道为什么我的原始代码停止工作,或者更好的是,如何修复它吗
编辑:
异常堆栈:
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
IO.File.Copy(“D:\Temp\Origin.log”,“D:\Temp\Destination.log”,True)
是否存在相同的问题?可能会有用。@AndrewMorton是的,它具有完全相同的问题problem@PhantomDj您可以将整个错误堆栈跟踪添加到问题中吗?我想知道这是否是一个相关的,这让我想知道你是否有一个旧版本的mscorlib.dll。或者如果D:的文件系统在工作时发生了更改。@AndrewMorton在原始帖子中添加了堆栈