Thursday, March 22, 2012
The file is being used by some other process
Am trying to read from and write to a same xml file.i have no prob when
reading the xml file.but when i write to the same file i get the following
error even after closing the reader object(which is open).
The file is being used by some other process.
regards
JagadeeshJagadeesh:
It'd help if you posted the code, but how are you reading the XML file?
DataSet.ReadXML or XMLReader? I'm guessing from your post it's the latter,
but if that's the case, why are you leaving the reader open? (I may be
misunderstanding your post, but if the reader is closed, how is it still
open?).
Let me see the code and hopefully I can be of more help.
Bill
"Jagadeesh" <jagamsc@.rediffmail.com> wrote in message
news:u$Omqfl2DHA.3196@.TK2MSFTNGP11.phx.gbl...
> hi ,
> Am trying to read from and write to a same xml file.i have no prob when
> reading the xml file.but when i write to the same file i get the following
> error even after closing the reader object(which is open).
> The file is being used by some other process.
> regards
> Jagadeesh
The file system has let me down (writing XML directly to the DB)
occasions, our XML files only get half-written from our application, we're
throwing up our hands and moving it into the DB.
So, instead of writing our XML files to the filesystem, I'm just going to
send the XML straight to a field in the DB and just grab it from there when
needed.
I have a few questions regarding that:
- preferred method? Right now, I'm using a FileStream:
Dim fs As New
System.IO.FileStream(System.Web.HttpContext.Curren t.Server.MapPath("/mjb05/rulesXML/"
& Trim(DS.Tables(0).Rows(rowCount)("filename").ToString) & ".xml"),
IO.FileMode.Create, IO.FileAccess.Write, IO.FileShare.Read)
If I'm going to send the text string right to the DB, what should I be
using? Stringbuilder and then just pass the XMLwriter to that?
- caching
One reason we liked the XML was that the server could easily cache it (we
access the XML on each page of our site). And the cache would only update
when the file was updated. If we store it in the database, we'd have to do a
query to see if it's been updated. Is that a big deal? Should we just cache
it every 5 minutes or so? Other preferred method?
-Darrel
--
================================================== ===============
Win prizes searching google:
http://www.blingo.com/friends?ref=h...FnTqhv-2GE1FNtAThus wrote darrel,
> After months of trying to track down a bug where, randomly, on rare
> occasions, our XML files only get half-written from our application,
> we're throwing up our hands and moving it into the DB.
> So, instead of writing our XML files to the filesystem, I'm just going
> to send the XML straight to a field in the DB and just grab it from
> there when needed.
> I have a few questions regarding that:
> - preferred method? Right now, I'm using a FileStream:
> Dim fs As New
> System.IO.FileStream(System.Web.HttpContext.Curren t.Server.MapPath("/m
> jb05/rulesXML/" &
> Trim(DS.Tables(0).Rows(rowCount)("filename").ToString) & ".xml"),
> IO.FileMode.Create, IO.FileAccess.Write, IO.FileShare.Read)
> If I'm going to send the text string right to the DB, what should I be
> using? Stringbuilder and then just pass the XMLwriter to that?
If your database has a native XML datatype and it's supported by its ADO.NET
provider, I'd use that -- one example is SQL Server (Express) 2005. You can
also get away using CLOBs or BLOBs if you don't care about the XML content
at database level (i.e. don't need to search within an XML document). That
should work with any old database.
> - caching
> One reason we liked the XML was that the server could easily cache it
> (we access the XML on each page of our site). And the cache would only
> update when the file was updated. If we store it in the database, we'd
> have to do a query to see if it's been updated. Is that a big deal?
> Should we just cache it every 5 minutes or so? Other preferred method?
Again, SQL Server 2005 comes to the rescue. Using a SqlCacheDependency, you
can easily implement an automatic refresh of your cached objects. See http://msdn.microsoft.com/library/d...otification.asp.
You can also emulate this feature using database triggers in other databases.
Cheers,
--
Joerg Jooss
news-reply@.joergjooss.de
The file system has let me down (writing XML directly to the DB)
occasions, our XML files only get half-written from our application, we're
throwing up our hands and moving it into the DB.
So, instead of writing our XML files to the filesystem, I'm just going to
send the XML straight to a field in the DB and just grab it from there when
needed.
I have a few questions regarding that:
- preferred method? Right now, I'm using a FileStream:
Dim fs As New
System.IO.FileStream(System.Web.HttpContext.Current.Server.MapPath("/mjb05/r
ulesXML/"
& Trim(DS.Tables(0).Rows(rowCount)("filename").ToString) & ".xml"),
IO.FileMode.Create, IO.FileAccess.Write, IO.FileShare.Read)
If I'm going to send the text string right to the DB, what should I be
using? Stringbuilder and then just pass the XMLwriter to that?
- caching
One reason we liked the XML was that the server could easily cache it (we
access the XML on each page of our site). And the cache would only update
when the file was updated. If we store it in the database, we'd have to do a
query to see if it's been updated. Is that a big deal? Should we just cache
it every 5 minutes or so? Other preferred method?
-Darrel
========================================
=========================
Win prizes searching google:
http://www.blingo.com/friends?ref=h...FnTqhv-2GE1FNtAThus wrote darrel,
> After months of trying to track down a bug where, randomly, on rare
> occasions, our XML files only get half-written from our application,
> we're throwing up our hands and moving it into the DB.
> So, instead of writing our XML files to the filesystem, I'm just going
> to send the XML straight to a field in the DB and just grab it from
> there when needed.
> I have a few questions regarding that:
> - preferred method? Right now, I'm using a FileStream:
> Dim fs As New
> System.IO.FileStream(System.Web.HttpContext.Current.Server.MapPath("/m
> jb05/rulesXML/" &
> Trim(DS.Tables(0).Rows(rowCount)("filename").ToString) & ".xml"),
> IO.FileMode.Create, IO.FileAccess.Write, IO.FileShare.Read)
> If I'm going to send the text string right to the DB, what should I be
> using? Stringbuilder and then just pass the XMLwriter to that?
If your database has a native XML datatype and it's supported by its ADO.NET
provider, I'd use that -- one example is SQL Server (Express) 2005. You can
also get away using CLOBs or BLOBs if you don't care about the XML content
at database level (i.e. don't need to search within an XML document). That
should work with any old database.
> - caching
> One reason we liked the XML was that the server could easily cache it
> (we access the XML on each page of our site). And the cache would only
> update when the file was updated. If we store it in the database, we'd
> have to do a query to see if it's been updated. Is that a big deal?
> Should we just cache it every 5 minutes or so? Other preferred method?
Again, SQL Server 2005 comes to the rescue. Using a SqlCacheDependency, you
can easily implement an automatic refresh of your cached objects. See http://msdn.
microsoft.com/l...on
.asp.
You can also emulate this feature using database triggers in other databases
.
Cheers,
--
Joerg Jooss
news-reply@.joergjooss.de