Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » finding text files in C# console applications
Closed Thread
Old 01-18-2009, 02:38 PM   #1 (permalink)
 
Junior Techie

Join Date: Nov 2008

Posts: 79

BobLewiston is on a distinguished road

Default finding text files in C# console applications

In C# console applications, isn't there a simpler way than handling exceptions to just find out if a text file of a given name exists in the current directory? I'm talking about something along the same lines as the following methods:

create text file:
Code:
StreamWriter SW = File.CreateText ("MyFile.txt");
open existing text file:
Code:
StreamReader SR = File.OpenText ("MyFile.txt");
append to text file:
Code:
StreamWriter SW  = File.AppendText ("MyFile.txt");

BobLewiston is offline  
Old 01-18-2009, 03:39 PM   #2 (permalink)
CrazeD's Avatar
 
Wizard Techie

Join Date: Feb 2006

Location: Maine

Posts: 3,683

CrazeD will become famous soon enough

Send a message via AIM to CrazeD Send a message via MSN to CrazeD
Default Re: finding text files in C# console applications

Code:
var getFile = new FileInfo(path);
if (getFile.Exists == true)
{
     // code
}
Like that?
__________________

Need website help? PM me!
CrazeD is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Any harmful services running? grkbar HijackThis Logs (finished) 2 10-10-2008 10:06 PM
Please Analyse, ethernet controller no longer working...[P] djmaddogfreak HijackThis Logs (finished) 16 07-04-2008 10:05 PM
friends log Static_11 HijackThis Logs (finished) 11 11-25-2007 10:27 PM