I have uploaded the file no problem. I have processing happening to the file and displaying to screen. However, once my processing is done I want to delete the original uploaded file.
I have tried:
//This bit works as expected to write the file to disk
outputFile = New FolderItem(file1.Name)
output = BinaryStream.Create(outputFile, True)
output.Write(file1.Data)
output.Close
//Tried this
file1.File.Remove()
//And this
outputFile.Remove()
Thoughts on how I can achieve this?
And I had it right. I just had the Remove in the wrong section of code. I had it placed below my exception and moving it above was the answer Rookie move.
Can you expand upon?
what wrong section of code?
what correct section of code?
If you could please answer It might help others
1 Like
The correct code was outputFile.Remove().
This is the correct way to code
For Each file1 As WebUploadedFile In files
Try
outputFile = New FolderItem(file1.Name)
output = BinaryStream.Create(outputFile, True)
output.Write(file1.Data)
output.Close
// Bunch of other code was here to process a CSV to a WebListBox
//CORRECT LOCATION OF REMOVE()
outputFile.Remove()
Catch e As IOException
Continue
//WHERE I HAD THE REMOVE() ORIGINALLY
End Try
1 Like