Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 试着表现出比我期望的更多_Vb.net - Fatal编程技术网

Vb.net 试着表现出比我期望的更多

Vb.net 试着表现出比我期望的更多,vb.net,Vb.net,我正在使用一个TRY-Catch块,我得到的错误和期望的结果如下: Throw New System.Exception("Copy of FileZilla file failed: " & ex.Message) 我得到的输出和以下顺序是: 创建FileZilla文件夹失败: 创建FileZilla文件失败: FileZilla文件复制失败:对路径“C:\Program Files(x86)\FileZilla Server”的访问被拒绝 为什么它会击中其他2个并同时

我正在使用一个TRY-Catch块,我得到的错误和期望的结果如下:

       Throw New System.Exception("Copy of FileZilla file failed: " & ex.Message)
我得到的输出和以下顺序是:

创建FileZilla文件夹失败: 创建FileZilla文件失败: FileZilla文件复制失败:对路径“C:\Program Files(x86)\FileZilla Server”的访问被拒绝

为什么它会击中其他2个并同时显示它们

        Dim sourceFile As FileInfo = New FileInfo(strSourcePathAndFile)

        Try
            ' Create the folder if it does not exist.
            If Not Directory.Exists(strDestinationFolder) Then
                Directory.CreateDirectory(strDestinationFolder)
            End If

            Try
                ' Create the file if it does not exist.
                If Not File.Exists(strDestinationPathAndFile) Then
                    File.Create(strDestinationPathAndFile)
                End If
                Try
                    ' Copy the source file to the destination file and overwrite it.
                    sourceFile.CopyTo(strDestinationPathAndFile, True)
                Catch ioex As IOException
                    Throw New System.Exception("Copy of FileZilla file I/O failed: " & ioex.Message)
                Catch ex As Exception
                    Throw New System.Exception("Copy of FileZilla file failed: " & ex.Message)
                End Try
            Catch ex As Exception
                Throw New System.Exception("Create of FileZilla file failed: " & ex.Message)
            End Try
        Catch ex As Exception
            Throw New System.Exception("Create of FileZilla folder failed: " & ex.Message)
        End Try
    End Sub

关于…

因为您抛出了新的异常,它会被另一个捕获块捕获,rinse&repeat


您的外部处理程序处理泛型异常类型,可能这就是您所要求的。将其更改为处理其他类型的异常。或者只使用一个Try…Catch块。

因为您抛出新异常,它会被另一个Catch块捕获,请清洗并重复


您的外部处理程序处理泛型异常类型,可能这就是您所要求的。将其更改为处理其他类型的异常。或者只使用一个Try…Catch块。

因为您抛出新异常,它会被另一个Catch块捕获,请清洗并重复


您的外部处理程序处理泛型异常类型,可能这就是您所要求的。将其更改为处理其他类型的异常。或者只使用一个Try…Catch块。

因为您抛出新异常,它会被另一个Catch块捕获,请清洗并重复


您的外部处理程序处理泛型异常类型,这可能就是您所要求的。将其更改为处理其他类型的异常。或者只使用一个Try…Catch块。

您正在捕获三个抛出的异常,因为您有三个Try…Catch级别

你还期待什么


最内层的Catch抛出一个新异常。中间的Catch自然会捕捉到这个异常,然后中间的Catch抛出一个新异常,最外层的Catch会捕捉到这个异常。

您正在捕捉三个抛出的异常,因为您有三个级别的Try…Catch

你还期待什么


最内层的Catch抛出一个新异常。中间的Catch自然会捕捉到这个异常,然后中间的Catch抛出一个新异常,最外层的Catch会捕捉到这个异常。

您正在捕捉三个抛出的异常,因为您有三个级别的Try…Catch

你还期待什么


最内层的Catch抛出一个新异常。中间的Catch自然会捕捉到这个异常,然后中间的Catch抛出一个新异常,最外层的Catch会捕捉到这个异常。

您正在捕捉三个抛出的异常,因为您有三个级别的Try…Catch

你还期待什么


最内层的Catch抛出一个新的异常。中间的Catch自然会捕捉到这个异常,然后抛出一个新的异常,最外层的Catch会捕捉到这个异常。

这是因为您正在使用嵌套的
try..Catch
块。错误是在多个级别出现的
Catch
。您可以尝试以下操作:

Dim sourceFile As FileInfo = New FileInfo(strSourcePathAndFile)
Dim error as String

    Try
        ' Create the folder if it does not exist.
        If Not Directory.Exists(strDestinationFolder) Then
            Directory.CreateDirectory(strDestinationFolder)
        End If

        Try
            ' Create the file if it does not exist.
            If Not File.Exists(strDestinationPathAndFile) Then
                File.Create(strDestinationPathAndFile)
            End If
            Try
                ' Copy the source file to the destination file and overwrite it.
                sourceFile.CopyTo(strDestinationPathAndFile, True)

            Catch ioex As IOException

                If String.IsNullOrEmpty(error) then _
                error = string.concat("Copy of FileZilla file I/O failed: ", ioex.Message)
            Catch ex As Exception

                If String.IsNullOrEmpty(error) then _
                error = string.concat("Copy of FileZilla file failed: ", ex.Message)
            End Try

        Catch ex As Exception

            If String.IsNullOrEmpty(error) then _
            error = string.concat("Create of FileZilla file failed: ", ex.Message)
        End Try

    Catch ex As Exception
        Throw New System.Exception(string.concat(error, ex.Message)
    End Try

End Sub

这是因为您正在使用嵌套的
try..catch
块。错误是在多个级别上出现的
catch
。您可以尝试以下操作:

Dim sourceFile As FileInfo = New FileInfo(strSourcePathAndFile)
Dim error as String

    Try
        ' Create the folder if it does not exist.
        If Not Directory.Exists(strDestinationFolder) Then
            Directory.CreateDirectory(strDestinationFolder)
        End If

        Try
            ' Create the file if it does not exist.
            If Not File.Exists(strDestinationPathAndFile) Then
                File.Create(strDestinationPathAndFile)
            End If
            Try
                ' Copy the source file to the destination file and overwrite it.
                sourceFile.CopyTo(strDestinationPathAndFile, True)

            Catch ioex As IOException

                If String.IsNullOrEmpty(error) then _
                error = string.concat("Copy of FileZilla file I/O failed: ", ioex.Message)
            Catch ex As Exception

                If String.IsNullOrEmpty(error) then _
                error = string.concat("Copy of FileZilla file failed: ", ex.Message)
            End Try

        Catch ex As Exception

            If String.IsNullOrEmpty(error) then _
            error = string.concat("Create of FileZilla file failed: ", ex.Message)
        End Try

    Catch ex As Exception
        Throw New System.Exception(string.concat(error, ex.Message)
    End Try

End Sub

这是因为您正在使用嵌套的
try..catch
块。错误是在多个级别上出现的
catch
。您可以尝试以下操作:

Dim sourceFile As FileInfo = New FileInfo(strSourcePathAndFile)
Dim error as String

    Try
        ' Create the folder if it does not exist.
        If Not Directory.Exists(strDestinationFolder) Then
            Directory.CreateDirectory(strDestinationFolder)
        End If

        Try
            ' Create the file if it does not exist.
            If Not File.Exists(strDestinationPathAndFile) Then
                File.Create(strDestinationPathAndFile)
            End If
            Try
                ' Copy the source file to the destination file and overwrite it.
                sourceFile.CopyTo(strDestinationPathAndFile, True)

            Catch ioex As IOException

                If String.IsNullOrEmpty(error) then _
                error = string.concat("Copy of FileZilla file I/O failed: ", ioex.Message)
            Catch ex As Exception

                If String.IsNullOrEmpty(error) then _
                error = string.concat("Copy of FileZilla file failed: ", ex.Message)
            End Try

        Catch ex As Exception

            If String.IsNullOrEmpty(error) then _
            error = string.concat("Create of FileZilla file failed: ", ex.Message)
        End Try

    Catch ex As Exception
        Throw New System.Exception(string.concat(error, ex.Message)
    End Try

End Sub

这是因为您正在使用嵌套的
try..catch
块。错误是在多个级别上出现的
catch
。您可以尝试以下操作:

Dim sourceFile As FileInfo = New FileInfo(strSourcePathAndFile)
Dim error as String

    Try
        ' Create the folder if it does not exist.
        If Not Directory.Exists(strDestinationFolder) Then
            Directory.CreateDirectory(strDestinationFolder)
        End If

        Try
            ' Create the file if it does not exist.
            If Not File.Exists(strDestinationPathAndFile) Then
                File.Create(strDestinationPathAndFile)
            End If
            Try
                ' Copy the source file to the destination file and overwrite it.
                sourceFile.CopyTo(strDestinationPathAndFile, True)

            Catch ioex As IOException

                If String.IsNullOrEmpty(error) then _
                error = string.concat("Copy of FileZilla file I/O failed: ", ioex.Message)
            Catch ex As Exception

                If String.IsNullOrEmpty(error) then _
                error = string.concat("Copy of FileZilla file failed: ", ex.Message)
            End Try

        Catch ex As Exception

            If String.IsNullOrEmpty(error) then _
            error = string.concat("Create of FileZilla file failed: ", ex.Message)
        End Try

    Catch ex As Exception
        Throw New System.Exception(string.concat(error, ex.Message)
    End Try

End Sub

如果您
throw
该错误,它将被抛出到下一个catch块。因为您使用的是嵌套的
Try..catch
块。该错误是由父对象执行的
catch
错误。此方法是新的…此方法可能会在任何操作中失败,因此我想向UI发送一条消息,定义失败的位置。因此我认为THROW NEW是通过将文本附加到方法中失败的位置来实现的方法。那么,正确的构造是什么来获得要传递的1节?这些节是否应该嵌套?如果我不嵌套,try catch在捕获后的行为是否会转到方法的末尾而不执行其他操作?如果如果您
throw
该错误,它将被抛出到下一个catch块。因为您使用的是嵌套的
Try..catch
块。该错误正由父对象执行
catch
。此方法是新的…此方法可能会在任何操作中失败,因此我想向UI发送一条消息,定义失败的位置。因此我认为他抛出NEW是一种方法,通过将文本附加到方法中失败的位置来实现。那么,正确的构造是什么来获得要传递的1节?这些节不应该嵌套吗?如果我不嵌套,try-catch在捕获后的行为是转到方法的末尾而不执行其他操作吗?如果是ou
throw
该错误将被抛出到下一个catch块。因为您使用的是嵌套的
Try..catch
块。该错误正由父对象引发。
catch
此方法是新的。……此方法可能会在任何操作中失败,因此我想向UI发送一条消息,定义失败的位置。因此我认为THROW NEW是通过将文本附加到方法中失败的位置来实现的方法。那么,正确的构造是什么来获得要传递的1节?这些节是否应该嵌套?如果我不嵌套,try catch在捕获后的行为是否会转到方法的末尾而不执行其他操作?如果
throw
该错误将被抛出到下一个catch块。因为您使用的是嵌套的
Try..catch
块。该错误正由父对象引发。
catch
此方法是新的。…此方法可能会在任何操作中失败,因此我想向UI发送一条消息,定义失败的位置。因此我认为HROW NEW是通过将文本附加到方法中的fai位置来实现的方法