I have a simple (what I believe is a simple) page that has the following on page load..
This code used to include code to create a directory of it didn't exist - for uploading a file via .NET.
The upload code works fine but I am getting a securityexception error on the End Sub line whenever I include the DIR function.
Currently, I am not really using it - I stripped it out and my later code - for uploading to the Upload folder works both locally and with my hosted solution.
However, I am still curious why I am getting the error. If I am able to upload a file from my form - using .NET, why can I not use the DIR function to read from the same folder. I will need to build a list of files from this folder soon.
Thanks.
Matthew Moran (career blog and podcast below)
Career Advice with Attitude for the IT Pro
Code:
Sub Page_Load(Sender as Object, e as EventArgs)
Dim MyPath, MyName As String
MyPath = Server.MapPath("Upload")
MyName = Dir(MyPath, vbDirectory)
End Sub
This code used to include code to create a directory of it didn't exist - for uploading a file via .NET.
The upload code works fine but I am getting a securityexception error on the End Sub line whenever I include the DIR function.
Currently, I am not really using it - I stripped it out and my later code - for uploading to the Upload folder works both locally and with my hosted solution.
However, I am still curious why I am getting the error. If I am able to upload a file from my form - using .NET, why can I not use the DIR function to read from the same folder. I will need to build a list of files from this folder soon.
Thanks.
Matthew Moran (career blog and podcast below)
Career Advice with Attitude for the IT Pro