I'd like to read the report or text file generated below (3rd from last line) into a textbox:
Dim config As New MarketplaceWebServiceConfig
config.ServiceURL = "https://mws.amazonservices.co.uk"
Dim myClient As New MarketplaceWebServiceClient(AccessKey, SecretKey, ApplicationName, ApplicationVersion, config)
Dim myRequest As New GetReportRequest
myRequest.Merchant = SellerID
myRequest.ReportId = reportId
myRequest.Report = File.Open("C:\\report\" + reportId.ToString + ".txt", FileMode.OpenOrCreate, FileAccess.ReadWrite)
Dim myResponse As New GetReportResponse
myResponse = myClient.GetReport(myRequest)
If I add a final line:
myTextbox.text = File.ReadAllText("C:\\report\" + reportId.ToString + ".txt")
I get "The process cannot access the file "xxx" because it is being used by another process."
What do I need to do to ensure the file is written to and closed before attempting to read from it?