TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Niklas Buhu
NA
11
0
Write to file
May 22 2010 8:32 AM
I am having a problem writing to files.
The problem is that I do not get the same result when running on windows xp and windows server 2003 as I do when I run it on a windows server 2008 machine.
The original code was from a larger program but after having debugged this for a day I decided to make a test-program.
My objective: To read a file, after having read 200 lines write lines to new file.
My result: On windows xp and 2003 machines I get 200 lines in new file. On windows 2008 machines I get 218 lines in new file.
Below is a simple test which for me behaves differently on win xp and 2008.
What am I doing wrong?
Code:
private
void
ProcessFile(
string
inputFileName,
string
outputFileName)
{
Encoding
encoding =
Encoding
.GetEncoding(65001);
List
<
string
> transactionlist =
new
List
<
string
>();
StreamReader
sr =
new
StreamReader
(inputFileName, encoding);
List
<
string
> splittedFiles =
new
List
<
string
>();
int
lineCount = 0;
int
maxLinesFile = 200;
while
(sr.Peek() != -1)
{
lineCount++;
transactionlist.Add(sr.ReadLine());
if
(lineCount == maxLinesFile)
break
;
}
sr.Close();
sr.Dispose();
File
.WriteAllLines(outputFileName, transactionlist.ToArray(), encoding);
return
;
}
Reply
Answers (
11
)
Delete link button in grid view is not working
how to write an xml file from form in extjs.....