简体   繁体   中英

File.Move Causing a TagetInvocationException?

I have a program that, after downloading some files, is moving them around the C drive. When I call file.move though, I get the following exceptions:

A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll

Additional information: Exception has been thrown by the target of an invocation.

If there is a handler for this exception, the program may be safely continued.

I know that this can happen when you don't actually have the directory but I do. It actually DOES move the files correctly, it just throws up an error. I can't find any information on this? Should I just try and catch this fake error or should I figure out what's going on? Thanks!

File.Move doesn't throw that type of exception. Or at least that is what the list of exceptions on MSDN says http://msdn.microsoft.com/en-us/library/system.io.file.move.aspx

So this may be caused by something else, please check the inner exception and investigate further.

有关此异常,请参见InnerException,您将知道原因。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM