Did you specify the Command line arguments ? It seems that your
program requires 2 arguments - An inputfile and an outputfile.
Try running it the following way :
---
MyConsoleApp.exe "c:\1.txt" "c:\2.txt"
---
and next time, please try to paste in formatted code.
On Nov 3, 2:24 pm, "VIKAS GARG" <[EMAIL PROTECTED]> wrote:
> This Program giving error But according to explanation this should ask the
> name of file to be created at the runtime and the file from which it will
> read data, its name will also be given a t the runtime but this never
> happened m new to this topic is there anyone who could explain this to me
> using System; using System.IO; class CopyFile { public static void
> Main(string[] args) { int i; FileStream fin; FileStream fout; try { // open
> input file try { fin = new FileStream(args[0], FileMode.Open); } catch
> (FileNotFoundException exc) { Console.WriteLine(exc.Message + "\nInput File
> Not Found"); return; } // open output file try { fout = new
> FileStream(args[1], FileMode.Create); } catch (IOException exc) {
> Console.WriteLine(exc.Message + "\nError Opening Output File"); return; } }
> catch (IndexOutOfRangeException exc) { Console.WriteLine(exc.Message +
> "\nUsage: CopyFile From To"); return; } // Copy File try { do { i =
> fin.ReadByte(); if (i != -1) fout.WriteByte((byte)i); } while (i != -1); }
> catch (IOException exc) { Console.WriteLine(exc.Message + "File Error"); }
> fin.Close(); fout.Close(); } }