Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

Could not find a part of the path 'D:\OLMS\'

Course Queries Syllabus Queries

Max. 2000 characters
Tuteehub
Replies

usr_profile.png

User

( 5 months ago )

 


Protected
Sub btnadd_sylbus_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnadd_sylbus.Click Dim extension As String = System.IO.Path.GetExtension(FileUpload_sylbus.PostedFile.FileName).ToLower() Dim Type As String = Nothing If (extension = ".pdf") Then Dim intFileNameLength As Integer Dim strFileNamePath As String Dim strFileNameOnly As String strFileNamePath = FileUpload_sylbus.PostedFile.FileName intFileNameLength = InStr(1, StrReverse(strFileNamePath), "\") strFileNameOnly = Mid(strFileNamePath, (Len(strFileNamePath) - intFileNameLength) + 2) Dim br As New BinaryReader(FileUpload_sylbus.PostedFile.InputStream) FileUpload_sylbus.PostedFile.SaveAs("D:\OLMS\" & strFileNameOnly) cmd.CommandText = "INSERT into Syllabus(sylbus_id, sylbus_name, file_name, content) values(@id,@name,@file,@cont)" cmd.Connection = cn cmd.Parameters.Add("@id", txtsylbus_id.Text) cmd.Parameters.Add("@name", txtsylbus_name.Text) cmd.Parameters.Add("@file", FileUpload_sylbus.FileName) cmd.Parameters.Add("@cont", br.ReadBytes(FileUpload_sylbus.PostedFile.ContentLength)) cmd.ExecuteNonQuery() cn.Close() lbladd_sylbus.Visible = True lbladd_sylbus.Text = "File Upload Success." txtsylbus_id.Text = Nothing txtsylbus_name.Text = Nothing Else lbladd_sylbus.Visible = True lbladd_sylbus.Text = "Not a Valid file format" End If End Sub

usr_profile.png

User

( 5 months ago )

You could try this code

strFileNamePath = FileUpload_sylbus.PostedFile.FileName
strFileNameOnly = Path.GetFilename(strFileNamePath)
Dim newFileNamePath as String = Path.Combine("D:\OLMS", strFileNameOnly)
Dim br As New BinaryReader(FileUpload_sylbus.PostedFile.InputStream)
FileUpload_sylbus.PostedFile.SaveAs(newFileNamePath)

Now, if you still get errors in accessing the folder D:\OLMS then you have this path outside the root folder of your site and your machine configuration (search about MEDIUM TRUST) disallows writing outside the root folder. (Of course I am assuming that the folder D:\OLMS exists and the user under which the IIS ASP.NET service is running has all the permissions to write in that folder)

what's your interest


forum_ban8_5d8c5fd7cf6f7.gif