how to write into a big textfile ?
am 09.11.2007 21:24:34 von Nicopil
Hello everybody, i need your help : i have to write some lines coming from a
database into a textfile;
Everything goes right while the filesize is quite small or medium; But it's
different when the file becomes a bit large, as it returns the following
error :
"The process cannot access the file because it is being used"
As my scripts were written in powershell using the function Add-Content, i
though it would be resolved by using the dotnet functions, building and
using StreamWriters or such possibilities...
but no way;
Actually, i thing the process of writing the stream into the textfile become
to slow when the filesize is big, and the following data are coming before
the first are on te file.
i don't know how to resolve my problem; is it possible to wait for the first
process to be finished before writing the new data into the file ?
Thx
Nico
RE: how to write into a big textfile ?
am 10.11.2007 05:12:01 von PRSoCo
If you have another applicatin writing to the file you'll have to wait for
the other application to finish. If it is your appplication you could use a
different sharing mode; but if you're writing to the start of the file and
moving the rest of the data in the file you're probably out of luck.
--
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#
"Nicopil@mi" wrote:
> Hello everybody, i need your help : i have to write some lines coming from a
> database into a textfile;
>
> Everything goes right while the filesize is quite small or medium; But it's
> different when the file becomes a bit large, as it returns the following
> error :
>
> "The process cannot access the file because it is being used"
>
> As my scripts were written in powershell using the function Add-Content, i
> though it would be resolved by using the dotnet functions, building and
> using StreamWriters or such possibilities...
> but no way;
>
> Actually, i thing the process of writing the stream into the textfile become
> to slow when the filesize is big, and the following data are coming before
> the first are on te file.
>
>
> i don't know how to resolve my problem; is it possible to wait for the first
> process to be finished before writing the new data into the file ?
>
> Thx
> Nico
>
>
>