Jag får lite titt som tätt fel på en xml-fil som det skrivs till med jämna mellanrum att den är låst av operativsystemet. Går inte ens att ta bort den i windows. Finns det något sätt att undvika detta?
public static void getNewsFromNGM(string pid)
{
try
{
StringBuilder sb = new StringBuilder();
// used on each read operation
byte[] buf = new byte[8192];
// prepare the web page we will be asking for
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.web.se/system/GetX.....");
// execute the request
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
// we will read data via the response stream
Stream resStream = response.GetResponseStream();
string tempString = null;
int count = 0;
do
{
// fill the buffer with data
count = resStream.Read(buf, 0, buf.Length);
// make sure we read some data
if (count != 0)
{
// translate from bytes to text
tempString = Encoding.Default.GetString(buf, 0, count);
// continue building the string
sb.Append(tempString);
}
}
while (count > 0); // any more data to read?
string f = HttpContext.Current.Request.MapPath("../pressreleaser/"+ pid +".xml").ToString();
StreamWriter sw = new StreamWriter(f, false, Encoding.Default);
sw.Write(sb.ToString());
sw.Close();
sw.Dispose();
}
catch { }
133 ms totalt · 3 externa anrop · v20260731065814-full.b746b907