run time error

N

nicol

hi
this program has run time error plz help me to solve it

using System;
using System.IO;

class Program
{
class file_data
{
string first_name_f;
string last_name_f;
decimal salary_f;
int id_f;
}
class file
{

public static void number1()
{
int number;
number = Int32.Parse(Console.ReadLine());
file[] emplyee_f = new file[number];
TextWriter write = new StreamWriter("data5:txt");
for (int i = 0; i < number; i++)
{
string n = Console.ReadLine();
write.WriteLine(n);
write.WriteLine(Console.ReadLine());
n = Console.ReadLine();
write.WriteLine(n);
n = Console.ReadLine();
int f = Convert.ToInt32(n);
write.WriteLine(f);
}
write.Close();
}

}


static void Main(string[] args)
{
file.number1();
}

}
 
F

Family Tree Mike

hi
this program has run time error plz help me to solve it

using System;
using System.IO;

class Program
{
class file_data
{
string first_name_f;
string last_name_f;
decimal salary_f;
int id_f;
}
class file
{

public static void number1()
{
int number;
number = Int32.Parse(Console.ReadLine());
file[] emplyee_f = new file[number];
TextWriter write = new StreamWriter("data5:txt");
for (int i = 0; i< number; i++)
{
string n = Console.ReadLine();
write.WriteLine(n);
write.WriteLine(Console.ReadLine());
n = Console.ReadLine();
write.WriteLine(n);
n = Console.ReadLine();
int f = Convert.ToInt32(n);
write.WriteLine(f);
}
write.Close();
}

}


static void Main(string[] args)
{
file.number1();
}

}

You are trying to open a stream to a file called "data5:txt". Do you
mean "data5.txt"?

Mike
 
N

nicol

hi
this program has run time error plz help me to solve it
using System;
using System.IO;
     class Program
     {
         class file_data
         {
             string first_name_f;
             string last_name_f;
             decimal salary_f;
             int id_f;
         }
         class file
         {
             public static void number1()
             {
                 int number;
                 number = Int32.Parse(Console.ReadLine());
                 file[] emplyee_f = new file[number];
                 TextWriter write = new StreamWriter("data5:txt");
                 for (int i = 0; i<  number; i++)
                 {
                     string n = Console.ReadLine();
                     write.WriteLine(n);
                     write.WriteLine(Console.ReadLine());
                     n = Console.ReadLine();
                     write.WriteLine(n);
                     n = Console.ReadLine();
                     int f = Convert.ToInt32(n);
                     write.WriteLine(f);
                 }
                 write.Close();
             }
         }
         static void Main(string[] args)
         {
             file.number1();
         }

You are trying to open a stream to a file called "data5:txt".  Do you
mean "data5.txt"?

Mike

oh thanks i think i am Wacky
 
A

Arne Vajhøj

using System;
using System.IO;

class Program
{
class file_data
{
string first_name_f;
string last_name_f;
decimal salary_f;
int id_f;
}
class file
{

public static void number1()
{
int number;
number = Int32.Parse(Console.ReadLine());
file[] emplyee_f = new file[number];
TextWriter write = new StreamWriter("data5:txt");
for (int i = 0; i< number; i++)
{
string n = Console.ReadLine();
write.WriteLine(n);
write.WriteLine(Console.ReadLine());
n = Console.ReadLine();
write.WriteLine(n);
n = Console.ReadLine();
int f = Convert.ToInt32(n);
write.WriteLine(f);
}
write.Close();
}

}


static void Main(string[] args)
{
file.number1();
}

}

When running the code you get:

Unhandled Exception: System.NotSupportedException: The given path's
format is not supported.

....

at System.IO.StreamWriter..ctor(String path)

That explains the problem pretty well.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

file [?] 2
interface 1
What's wrong with Private keyword 7
How do a loop this program? Learning CSharp 3
error :( 4
usage of this() 6
How to download http file. 2
Easy question 1

Top