to save xml file in

Public Function UploadCourseXML(ByVal fileStream As String, companyID As Integer, ByVal tokenID As String) As String Implements ICorePointService.UploadCourseXML

        If (Not IsCustomerAuthentication(companyID, tokenID)) Then
            Throw New Exception("Authentication failed. Please provider Company ID and Token ID")
        End If

        Dim doc As XDocument = XDocument.Parse(fileStream)

        doc.Save("Update_XML")' error occures here... Access to the path c:\...etc.  is denied
                                             ..  i want to save this in solution explorer

        Return "result"
    End Function


Refer this link :

This for windows & web also

Imports System.IO Imports System.Net Imports System.Xml

Public Class Form1

  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    'To just download xml text
    'Download text and save
    Dim wc As New WebClient
    Dim xmlText As String = wc.DownloadString("")
    File.WriteAllText("new file path.xml", xmlText)


    'To load stream directly into XML Document :

    'Get data in stream
    Dim webRequest As WebRequest = webRequest.Create("")
    Dim webResponse As WebResponse = webRequest.GetResponse
    Dim webStream As Stream = webResponse.GetResponseStream

    'If you want you can read text from stream
    'Dim reader As New StreamReader(webStream)
    'reader.ReadToEnd 'will give same output as wc.downloadString()

    'Load stream
    Dim xmlDoc As New XmlDocument

    'select any level nodes using xpath
    Dim Nodes As XmlNodeList = xmlDoc.SelectNodes("//lca-data/prefix/exch")

    'iterate in selected nodes
    For Each node As XmlNode In Nodes
      RichTextBox1.AppendText(node.InnerText & vbCrLf)

  End Sub

End Class

You'll get a Access to the path '...' is denied error if the folder is flagged ReadOnly. You need to remove this flag prior to saving the file.

Dim info As DirectoryInfo = New DirectoryInfo("C:\folder1\folder2\folder3")

If (info.Exists AndAlso ((info.Attributes And FileAttributes.[ReadOnly]) = FileAttributes.[ReadOnly])) Then
    info.Attributes = (info.Attributes Xor FileAttributes.[ReadOnly])
End If

If you're writing to an existing file, also make sure the file is not flagged ReadOnly. Just change DirectoryInfo to FileInfo.

Dim info As FileInfo = New FileInfo("C:\folder1\folder2\folder3\file.ext")

You may refer to the below given link to find out your problem,

Need Your Help

Unable to iterate over list


I'm appending to a list then throwing that list into a function below:

comboBox width depending on longest item

c# combobox

i've got a ComboBox that i generate dynamically and fill with some items. i would like to set this control's width to the width of the longest item. how do i count the display width of some text?