Cant copy a complete text file
-
hi!! m back... this time i thinks its a very basic problem... i'm trying to copy all the contents of a file(a txt file of 700 lines) when i write it in another file, it writes 75% of text.... it leaves the rest... y??? i dont understand... i'm using stream reader n writer... is it the way to do it..
-
hi!! m back... this time i thinks its a very basic problem... i'm trying to copy all the contents of a file(a txt file of 700 lines) when i write it in another file, it writes 75% of text.... it leaves the rest... y??? i dont understand... i'm using stream reader n writer... is it the way to do it..
ayandelhi wrote:
i dont understand...
Without seeing any code I doubt anyone else will either. :-D Why not just use File.Copy()? (If there was some code it might explain why you cannot use it. :) )
Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis The only valid measurement of code quality: WTFs/minute.
-
hi!! m back... this time i thinks its a very basic problem... i'm trying to copy all the contents of a file(a txt file of 700 lines) when i write it in another file, it writes 75% of text.... it leaves the rest... y??? i dont understand... i'm using stream reader n writer... is it the way to do it..
Is the problem that you are missing the <CR><LF> characters from your output file and are you using
ReadLine()
[^] to read your input file? If so, note that the line end characters <CR> and/or <LF> do not get copied into your input buffer.It's time for a new signature.
-
ayandelhi wrote:
i dont understand...
Without seeing any code I doubt anyone else will either. :-D Why not just use File.Copy()? (If there was some code it might explain why you cannot use it. :) )
Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis The only valid measurement of code quality: WTFs/minute.
static string file=""; static string line=""; static void Main(string[] args) { StreamReader sr=new StreamReader("d:\\file1.txt"); StreamWriter sw=new StreamWriter("D:\\file2.txt"); while((line=sr.Readline())!=null) { file="\""+line+"\\r\\n";\\editing the line read from the file sr.WriteLine(file); file=""; } }
file 1 has abt 700 lines and file2 is destination... -
hi!! m back... this time i thinks its a very basic problem... i'm trying to copy all the contents of a file(a txt file of 700 lines) when i write it in another file, it writes 75% of text.... it leaves the rest... y??? i dont understand... i'm using stream reader n writer... is it the way to do it..
if you want help with your code, do not tell us anything or show us any code! The easy ways out: File.Copy File.WriteAllBytes(File.ReadAllBytes()) :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
-
hi!! m back... this time i thinks its a very basic problem... i'm trying to copy all the contents of a file(a txt file of 700 lines) when i write it in another file, it writes 75% of text.... it leaves the rest... y??? i dont understand... i'm using stream reader n writer... is it the way to do it..
close your writer when your done, it's probably just not flushing...
sw.close();
also your are calling write line on a stream reader instead of your stream writer... -
close your writer when your done, it's probably just not flushing...
sw.close();
also your are calling write line on a stream reader instead of your stream writer... -
close your writer when your done, it's probably just not flushing...
sw.close();
also your are calling write line on a stream reader instead of your stream writer...