Kako u asp.net-u (vb.net i c#) čitati i zapisivati u datoteku koja se nalazi u root direktoriju (C:\Inetpub\wwwroot)?


Imports System.IO 

' zapiši u .txt datoteku
Dim writer As StreamWriter = File.CreateText("Server.MapPath("/file.txt"):") 
writer.WriteLine("Ovo je jedna linija.") 
' zatvori StreamWriter
writer.Close() 

' procitaj sve linije u .txt datoteci
Dim reader As StreamReader = File.OpenText("Server.MapPath("/file.txt")") 
Dim line As String = reader.ReadLine() 

While Not line Is Nothing 
  Response.Write(line + "<br>") 
  line = reader.ReadLine() 
End While 

' zatvori StreamReader
reader.Close()