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

Course Queries Syllabus Queries 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Syllabus Queries related to Course Queries. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years 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
profilepic.png
manpreet 2 years 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)


0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.