Make an xml file writeable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jaleel
    New Member
    • Sep 2007
    • 38

    Make an xml file writeable

    In a windows application I have an xml file which is readable and writeable. I wnat to ensure that this file is writeable if it is set to read-only.



    I am doing my work using the code:



    Code:
    Dim afpXmlDocumnet As XmlDocument = New XmlDocument
    afpXmlDocumnet.Load(filename)
    
    'reading some nodes
    ............................
    
    'writing to some node
    ............................
    
    'saving the file
    afpXmlDocumnet.Save(appPath)

    the code at line number 11 throws an exception when file is read-only. What should I do to avoid this ? How to make it writeable? Any help...
    Last edited by jaleel; Oct 27 '07, 12:10 PM. Reason: one info. was missing
  • jaleel
    New Member
    • Sep 2007
    • 38

    #2
    Hi

    I tried with this piece of code before writing to the file :

    Dim fileInformation As New FileInfo(filena me)
    If fileInformation .IsReadOnly Then
    fileInformation .Attributes = FileAttributes. Normal
    End If

    Now it works ...

    Comment

    Working...