索引超出了数组范围

时间:2015-08-26 18:41:20

标签: c#

我正在尝试使用安全删除扩展,但是当我执行它时,我得到了Index超出数组的范围。我已经添加了ddl文件作为参考

http://microsoftwinanyhelper.codeplex.com/documentation

    using Microsoft.WinAny.IO;
   //showing only relevant part here 
    private void button1_Click(object sender, EventArgs e)
            {
                System.IO.FileInfo fi = new System.IO.FileInfo(@"C:\test.jpg");
                fi.Delete(OverwriteAlgorithm.DoD_7);
            }

以下是有关错误的更多详细信息。 编辑1 我粘贴了错误的错误家伙。它发生了,因为我第二次点击删除第二次收到错误消息,因此出现了使用中的文件问题

这是正确的

An unhandled exception of type 'System.IndexOutOfRangeException' occurred in Microsoft.WinAny.Helper.dll

Additional information: Index was outside the bounds of the array.



See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at Microsoft.WinAny.IO.SecureDeleteExtensions.OverwriteFile_DoD_7(FileInfo file)
   at Microsoft.WinAny.IO.SecureDeleteExtensions.Delete(FileInfo file, OverwriteAlgorithm overwriteAlgorithm)
   at UltimateDelete.Form1.button1_Click(Object sender, EventArgs e) in c:\Users\Gr33k\Documents\Visual Studio 2013\Projects\UltimateDelete\UltimateDelete\Form1.cs:line 43
   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.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
UltimateDelete
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Users/Gr33k/Documents/Visual%20Studio%202013/Projects/UltimateDelete/UltimateDelete/bin/Debug/UltimateDelete.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.34251 built by: FX452RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.34238 built by: FX452RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Configuration
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.34234 built by: FX452RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
Microsoft.WinAny.Helper
    Assembly Version: 1.0.1.0
    Win32 Version: 1.0.1.0
    CodeBase: file:///C:/Users/Gr33k/Documents/Visual%20Studio%202013/Projects/UltimateDelete/UltimateDelete/bin/Debug/Microsoft.WinAny.Helper.DLL
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

1 个答案:

答案 0 :(得分:0)

你的例外说了别的话:

System.IO.IOException: The process cannot access the file 'C:\test.jpg' because it is being used by another process.

所以你应该解决这个问题。这几乎是不言自明的。

编辑(在更正问题之后):看起来引用的程序集中发生异常。可能是一个错误。

编辑:代码中的异常似乎超出了您的范围。您也可以将其报告为错误。