سؤال

I created a Windows service to upload files from client to a shared folder on a server having a shared permission with everyone has a full control over it using Microsoft BITS service, this service runs with the local system account. The issue is that BITS jobs always get cancelled and I don't know why. Please any help will be appreciated.

I'm using this code

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
هل كانت مفيدة؟

المحلول

I figure it out, the security permissions on the shared folder were not set on the remote server, I did it then every thing goes smooth.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top