Delete a file in Local server after transferring the file

Advertisement

BLawrence
Joined:
Posts:
1

Delete a file in Local server after transferring the file

Dim transferOptions = New TransferOptions
transferOptions.ResumeSupport.State = TransferResumeSupportState.Off
transferOptions.PreserveTimestamp = False

transferResult = session.PutFiles(UploadFromFolder + filename.FileName, ClientFolderPath, False, transferOptions)

transferResult.Check()
File.Copy(UploadFromFolder + filename.FileName, BackupFolder + Path.GetFileName(filename.FileName))

File.Delete(UploadFromFolder + filename.FileName)

File.Delete gives error that the file is used by another process and cannot delete. It is just a text file and the transfer somehow locks it I think.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,286
Location:
Prague, Czechia

Re: Delete a file in Local server after transferring the file

What protocol are you using?
Can you post a session log file?
Though I do not think it's WinSCP that locks the file. Did you try to turn off antivirus?
Did you try using File.Move instead of File.Copy and File.Delete?

Reply with quote

Advertisement

You can post new topics in this forum