簡體   English   中英

從客戶端計算機讀取XML文件-獲取-拒絕訪問路徑

[英]Reading XML file from Client machine - getting - Access to the path is denied

我目前正在嘗試從客戶端計算機上讀取XML文件,用戶可以從任何位置打開該文件(沒有特定位置)。 但是,我瀏覽到該文件夾​​並選擇xml文件,當它執行此行時(下面),它會拋出一個錯誤,抱怨對路徑的訪問被拒絕了,我不知道該怎么辦?

錯誤: System.UnauthorizedAccessException:對路徑的訪問被拒絕

Dim reader As New XmlTextReader(System.IO.Path.GetFullPath(File1.PostedFile.FileName)) 

            Dim m_xmlr As XmlTextReader
            'Create the XML Reader
            m_xmlr = New XmlTextReader(System.IO.Path.GetFullPath(File1.PostedFile.FileName.ToString()))
            'Disable whitespace so that you don't have to read over whitespaces
            m_xmlr.WhitespaceHandling = WhitespaceHandling.None
            'read the xml declaration and advance to family tag
            m_xmlr.Read()   **<<<<<ERROR**
            'read the family tag
            m_xmlr.Read()
            'Load the Loop
            While Not m_xmlr.EOF
                 ..............
                 .............

您的代碼正在服務器上運行。 您不能像這樣從客戶端的本地驅動器讀取數據。 您應該使用文件的InputStream來獲取數據。 例如:

Dim m_xmlr As XmlReader = XmlReader.Create(File1.PostedFile.InputStream)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM