Reading and Writing to the file using Stream Reader and Stream Writer
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace PNB
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Hi all,
Above contain the code for reading the data and write from one format to another and vice versa
But the problem is that at runtime, here suppose one file is in T004 format and i am writing to txt format it creates the empty file and it goes to catch block giving error which is present in the MessageBox.show and creates the empty file. and when i take txt file it sucessfully convert to respective format sucessfully
Can anyone help with the same
Thanks and Regards
Re: Reading and Writing to the file using Stream Reader and Stream Writer
1) Next time please us [code][/code] tags around your code to preserve the formatting. as it is, it's hard to follow.
2) Where does the error happen? Try noting with a comment or [b][/b] tags to mark the line with the error.
3) What is the error? That's nice that it's displayed in the messagebox, but we're not sitting at your computer so we can't see what the error is.
Re: Reading and Writing to the file using Stream Reader and Stream Writer
Originally Posted by Arjun-Sarankulu
I have written try catch block
It goes in the catch block
and Print "error:" as msg in message box
Thank for your comments
Exactly what error are you getting? Please be specific with your question so we can provide help. Also, please point out where in that giant string of code the error is being raised.
Re: Reading and Writing to the file using Stream Reader and Stream Writer
Thanks Sir for your comment
Its giving the exception and goes to catch block and display the respective error message present in Message Box.
I want to say that if i am taking txt file from file browser it convert to the respective format.
But for eg. file type is T004 ,etc it create the emty file and display the message present in catch block
I think the problem is related to text format of the file(Encoding problem,think so).
Can any one help what to be standardised
Re: Reading and Writing to the file using Stream Reader and Stream Writer
That loud banging you hear is me banging my head on the desk. Yes, we know that it is displaying the respective error in a message box. We can see that much from the code. The question is WHAT is the TEXT of the ERROR MESSAGE that is being displayed? Does it say "I'm sorry Dave I cannot do that." Or does it say "Remove eels from your hovercraft to continue." Or does it say a bunch of curse words? OR does it complain that the wheels fell off the car? How about a screen shot of the message box? That would help.
Re: Reading and Writing to the file using Stream Reader and Stream Writer
OK, now we're getting somewhere. Was that so hard? OK... two things... 1) Could you PLEASE repost your code, this time with [code][/code] tags around it so that it preserves the indenting? I am having trouble following your code and seeing where things start and end. Secondly, can you remove (or comment out) the Try/catch? That way when it errors out, it should go into debug mode and show you what line is causing the error. You have so much code in the try at the moment, I'm not sure where to begin to look for the error. Once you know what line the error happens on, either post the line, or mark it in the code with a comment or highlight or change it's color somehow.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.