Hi
This is probably pretty basic, but I have a problem with the access-level
(local variable), when creating a new StreamWriter. I am trying to write
some price information to a textfile - which works fine. But due to the
dataamounts involved I now need to split it out to several files.
The actions I am taking are:
- create the first file
- write data (pricelists) to file
- when number of pricelist = maxAllowed create new file with filename +1
- write the next data to the new file
But when I create a new StreamWriter in my textblock, I am creating a local
variable. I tried instead to set a static StreamWriter + FileInfo with
nullvalues. In my IF-block I assigned the FileInfo to the StreamWriter -
ie. sw = fi.CreateText(). But then I am not able (AFAIK) to set the file as
Unicode - which is a prerequisite.
My program structure is: (I know that the StreamWriters won´t work this way)
while ((line = customerList.ReadLine())!=null)
{
if(priceListCount==1 & fileCount==1)
{
outPriceFileName = "c:\\test\\out.txt";
StreamWriter outStream = new
StreamWriter(outPriceFileName, false, System.Text.Encoding.Unicode);
}
else if(priceListCount=maxAllowed)
{
outPriceFileName = "c:\\test\\out" + fileCount + ".txt";
StreamWriter outStream = new
StreamWriter(outPriceFileName, false, System.Text.Encoding.Unicode);
fileCount++
}
Perform some more operations and write data to StreamWriter }
Regards
Lars