Access to the path 'C:\Documents and Settings\ananth\My Documents\Visual Studio 2005\WebSites\text\FileUpload' is denied.
Imports System.Data.SqlClient Imports CrystalDecisions.CrystalReports.Engine Imports CrystalDecisions.Shared Imports System.IO Imports System.Data Imports System.Configuration Imports System.Security.Principal Imports System.Web.Security Partial Class FileUpload Inherits System.Web.UI.Page Dim myConnection As SqlConnection Dim myCommand As SqlCommand Dim rdr As SqlDataReader Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click Dim ra As Integer If Not (myFile.PostedFile Is Nothing) Then Dim intFileNameLength As Integer Dim strFileNamePath As String Dim strFileNameOnly As String 'Logic to find the FileName (excluding the path) strFileNamePath = myFile.PostedFile.FileName intFileNameLength = InStr(1, StrReverse(strFileNamePath), "\") strFileNameOnly = Mid(strFileNamePath, (Len(strFileNamePath) - intFileNameLength) + 2) myFile.PostedFile.SaveAs("C:\Documents and Settings\ananth\My Documents\Visual Studio 2005\WebSites\text\FileUpload" & strFileNameOnly) lblFileContentType.Text = "File Upload Success:-" & CStr(myFile.PostedFile.ContentLength) & " bytes" 'lblFileContentType.Text = "Content type: " & MyFile.PostedFile.ContentType 'lblFileSize.Text = "File size: " & CStr(myFile.PostedFile.ContentLength) & " bytes" myConnection = New SqlConnection("server=172.18.0.6;uid=sa;pwd=logmein;database=ananth") 'you need to provide password for sql server myConnection.Open() myCommand = New SqlCommand("Insert into fileupload(filename,link) values('" + TextBox1.Text + "','" + FileUpload1.FileName + "')", myConnection) ra = myCommand.ExecuteNonQuery() 'Since no value is returned we use ExecuteNonQuery Response.Write("Records Inserted" & ra) myConnection.Close() End If End Sub End Class
OP wrote:Access to the path 'C:\Documents and Settings\ananth\My Documents\Visual Studio 2005\WebSites\text\FileUpload' is denied
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)