0

我创建了一个 Windows 服务,用于将文件从客户端上传到服务器上的共享文件夹,该服务器与每个人都有共享权限,可以使用 Microsoft BITS 服务完全控制它,该服务使用本地系统帐户运行。问题是 BITS 作业总是被取消,我不知道为什么。请任何帮助将不胜感激。

我正在使用此代码

Try
            Using BITSManager = New System.Net.BITS.Manager
                For Each sItem In arrlDriversFilesUploadList
                    Using job = New System.Net.BITS.Job("UploadJob", Net.BITS.JobType.Upload)
                        Dim sRemoteFileName As String = String.Format("{0}\{1}", "\\RemoteServer\SharedFolder", "File.txt")
                        Dim sLocalFileName As String = String.Format("{0}\{1}", "C:\LocalLocation", "File.txt")
                        job.Files.Add(sRemoteFileName, sLocalFileName)
                        BITSManager.Jobs.Add(job)
                        job.NoProgressTimeout = 300 '5 Minutes
                        job.Resume()
                        Dim JobComplete As Boolean = False
                        Do Until JobComplete
                            System.Threading.Thread.Sleep(3000)

                            If job.State = System.Net.BITS.JobState.Transferred Then
                evntlg.WriteEntry("Job done")
                                    JobComplete = True
                            End If

                            If job.State = System.Net.BITS.JobState.Acknowledged Then
                evntlg.WriteEntry("Job done")
                                    JobComplete = True
                            End If

                            If job.State = System.Net.BITS.JobState.Error Then
                evntlg.WriteEntry("Job has error")
                                    JobComplete = True
                            End If

                            If job.State = System.Net.BITS.JobState.Cancelled Then
                evntlg.WriteEntry("Job cancelled")
                                    JobComplete = True
                            End If

                        Loop
                    End Using
                Next
            End Using

        Catch ex As Exception
            evntlg.WriteEntry(ex.Message)
        End Try
4

1 回答 1

0

我弄明白了,远程服务器上没有设置共享文件夹的安全权限,我做到了,然后一切顺利。

于 2012-02-21T10:39:59.627 回答