473,396 Members | 1,915 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Change filename of StreamWriter?

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
Nov 15 '05 #1
1 7537
> (hint: declare local variable and assign value of local var to global -
maybe I should patent that and sue someone)

Keep thinking like that and you'll be running a west-coast software
company before you know it :)

"Lars Hansen" <madknight@___remove___post.cybercity.dk> wrote in message news:<VR********************@news.easynews.com>... Went shopping
Had something to eat
Got back and looked at the code

Realized that my question was somewhat stupid


Glad to see walking away from the problem fixed it for you. I find
myself doing that sometimes. Just leave. Walk away. Clear the head.
Come back fresh and ready to rock!
Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Thu | last post by:
Can anyone help me please.. I am using vb.net to WriteXML from Ms Access tables to an output stream. Basically, I retrieve data from 3 tables then use DataRelations to link these three tables,...
1
by: Trevor | last post by:
Also posted in general ASP.NET forum. System.IO.IOException: The filename, directory name, or volume label syntax is incorrect. I have hit a problem for which I can find no solutions. Has...
5
by: José Joye | last post by:
I have a instance of a StreamWriter and I need to get the path and filename to which it is attached to. This sounds easy.... I feel a bit idiot not finding it! José
2
by: Tom Jones | last post by:
I am handed a reference to a StreamWriter object. I need to obtain the name of the underlying file name that this writer is associated with. I can't find a method to do so - am I missing...
4
by: Fabian | last post by:
Hi I want to change the content of text file. I use an StreamReader to read but I can´t use a StreamWriter for the same Stream. What I must do to implement content changing? Thanks for...
4
by: news.microsoft.com | last post by:
Hello All, im am new to ASP.NET, so bare with me. i have an application that i am building in stages. stage1 user picks data required stage2 file is written to a virutal directory Stage3...
1
by: Thu | last post by:
Hi, I create a Dataset to link three tables in my Access database. E.g. The three tables are , , . I then create 2 DataRelations, 1st relation (Order_Cust_Rel) links and using CustomerID field...
1
by: herbert | last post by:
I am using a TraceSource object configured via app.config. In order to delete the old file before starting the new trace, I need to obtain the filename from the listener. What am I doing wrong in...
3
by: Diego F. | last post by:
Hi. I'm using that code: If File.Exists(Ls_NombreFichero) = False Then sw = File.CreateText(Ls_NombreFichero) Else sw = File.AppendText(Ls_NombreFichero) End If I need to change the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.