Jump to content

Downloading error


wooikeim
 Share

Recommended Posts

sub Datagrid1_ItemCommand (sender as object, e as DataGridCommandEventArgs) if (e.CommandName= "Download") then Response.ContentType = "application\octet-stream" Dim filename as string=new string("C:\Inetpub\wwwroot\tution\doc") Dim downloadFile As System.IO.FileStream = New System.IO.FileStream(filename, IO.FileMode.Open) Response.Write(downloadFile.Length() & "#") downloadFile.Close() Response.WriteFile(filename) Response.Flush() Response.End()I got the problem in downloading a file, it show me End of statement expected. i not sure my code correct or not. please kindly tell me what happen here. thanks......this line is highlighted <Dim downloadFile As System.IO.FileStream = New System.IO.FileStream(filename, IO.FileMode.Open) >

Link to comment
Share on other sites

Try giving Response.write...... in next line.Response.ContentType = "application\octet-stream"Dim filename as string=new string("C:\Inetpub\wwwroot\tution\doc")Dim downloadFile As System.IO.FileStream = New System.IO.FileStream(filename, IO.FileMode.Open) Response.Write(downloadFile.Length() & "#")downloadFile.Close()Response.WriteFile(filename)Response.Flush()Response.End()

Link to comment
Share on other sites

Oh, I'm so sorry, didnt see that statement. Anyway, i have put it in the next line, but then got another error.Dim downloadFile As System.IO.FileStream = New System.IO.FileStream(filename, IO.FileMode.Open) <Access denied >error msg- To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.I had follow that instruction but still cant work

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...