<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FFile_Stream%2FFile</id>
		<title>Csharp/C Sharp/File Stream/File - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FFile_Stream%2FFile"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/File_Stream/File&amp;action=history"/>
		<updated>2026-04-29T17:59:17Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/File_Stream/File&amp;diff=1274&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/File_Stream/File&amp;diff=1274&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:19Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/File_Stream/File&amp;diff=1275&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/File_Stream/File&amp;diff=1275&amp;oldid=prev"/>
				<updated>2010-05-26T11:45:31Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Delete a file ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.IO;&lt;br /&gt;
class MainClass {&lt;br /&gt;
    static void Main() {&lt;br /&gt;
        string tempFile = Path.GetTempFileName();&lt;br /&gt;
        Console.WriteLine(&amp;quot;Using &amp;quot; + tempFile);&lt;br /&gt;
        using (FileStream fs = new FileStream(tempFile, FileMode.Open)) {&lt;br /&gt;
            // (Write some data.)&lt;br /&gt;
        }&lt;br /&gt;
        // Now delete the file.&lt;br /&gt;
        File.Delete(tempFile);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==File class to check whether a file exists, open and read==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
C# Programming Tips &amp;amp; Techniques&lt;br /&gt;
by Charles Wright, Kris Jamsa&lt;br /&gt;
Publisher: Osborne/McGraw-Hill (December 28, 2001)&lt;br /&gt;
ISBN: 0072193794&lt;br /&gt;
*/&lt;br /&gt;
// cp.cs -- Uses methods in the File class to check whether a file exists.&lt;br /&gt;
//          If it exists, it then opens and reads the file to the console.&lt;br /&gt;
//&lt;br /&gt;
//          Compile this program with the following command line&lt;br /&gt;
//              C:&amp;gt;csc cp.cs&lt;br /&gt;
using System;&lt;br /&gt;
using System.IO;&lt;br /&gt;
namespace nsStreams&lt;br /&gt;
{&lt;br /&gt;
    public class cp&lt;br /&gt;
    {&lt;br /&gt;
        static public void Main (string [] args)&lt;br /&gt;
        {&lt;br /&gt;
            if (args.Length &amp;lt; 2)&lt;br /&gt;
            {&lt;br /&gt;
                Console.WriteLine (&amp;quot;usage: cp &amp;lt;copy from&amp;gt; &amp;lt;copy to&amp;gt;&amp;quot;);&lt;br /&gt;
                return;&lt;br /&gt;
            }&lt;br /&gt;
            if (!File.Exists (args[0]))&lt;br /&gt;
            {&lt;br /&gt;
                Console.WriteLine (args[0] + &amp;quot; does not exist&amp;quot;);&lt;br /&gt;
                return;&lt;br /&gt;
            }&lt;br /&gt;
            bool bOverwrite = false;&lt;br /&gt;
            if (File.Exists (args[1]))&lt;br /&gt;
            {&lt;br /&gt;
                Console.Write (args[1] + &amp;quot; already exists. Overwrite [Y/N]? &amp;quot;);&lt;br /&gt;
                string reply = Console.ReadLine ();&lt;br /&gt;
                char ch = (char) (reply[0] &amp;amp; (char) 0xdf);&lt;br /&gt;
                if (ch != &amp;quot;Y&amp;quot;)&lt;br /&gt;
                    return;&lt;br /&gt;
                bOverwrite = true;&lt;br /&gt;
            }&lt;br /&gt;
            File.Copy (args[0], args[1], bOverwrite);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Get File Access Control==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using System;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Security.AccessControl;&lt;br /&gt;
class MainClass {&lt;br /&gt;
    static void Main(string[] args) {&lt;br /&gt;
        FileStream stream;&lt;br /&gt;
        string fileName;&lt;br /&gt;
        fileName = Path.GetRandomFileName();&lt;br /&gt;
        using (stream = new FileStream(fileName, FileMode.Create)) {&lt;br /&gt;
            // Do something.&lt;br /&gt;
        }&lt;br /&gt;
        SetRule(fileName, &amp;quot;Everyone&amp;quot;, FileSystemRights.Read, AccessControlType.Deny);&lt;br /&gt;
        try {&lt;br /&gt;
            stream = new FileStream(fileName, FileMode.Create);&lt;br /&gt;
        } catch (Exception ex) {&lt;br /&gt;
            Console.WriteLine(ex.ToString());&lt;br /&gt;
        } finally {&lt;br /&gt;
            stream.Close();&lt;br /&gt;
            stream.Dispose();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    static void AddRule(string filePath, string account, FileSystemRights rights, AccessControlType controlType) {&lt;br /&gt;
        FileSecurity fSecurity = File.GetAccessControl(filePath);&lt;br /&gt;
        fSecurity.AddAccessRule(new FileSystemAccessRule(account, rights, controlType));&lt;br /&gt;
        File.SetAccessControl(filePath, fSecurity);&lt;br /&gt;
    }&lt;br /&gt;
    static void SetRule(string filePath, string account, FileSystemRights rights, AccessControlType controlType) {&lt;br /&gt;
        FileSecurity fSecurity = File.GetAccessControl(filePath);&lt;br /&gt;
        fSecurity.ResetAccessRule(new FileSystemAccessRule(account, rights, controlType));&lt;br /&gt;
        File.SetAccessControl(filePath, fSecurity);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Get file Creation Time==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Mastering Visual C# .NET&lt;br /&gt;
by Jason Price, Mike Gunderloy&lt;br /&gt;
Publisher: Sybex;&lt;br /&gt;
ISBN: 0782129110&lt;br /&gt;
*/&lt;br /&gt;
 /*&lt;br /&gt;
  Example15_3.cs illustrates the File class&lt;br /&gt;
*/&lt;br /&gt;
using System;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
using System.IO;&lt;br /&gt;
public class Example15_3 &lt;br /&gt;
{&lt;br /&gt;
    [STAThread]&lt;br /&gt;
  public static void Main() &lt;br /&gt;
  {&lt;br /&gt;
    // create and show an open file dialog&lt;br /&gt;
    OpenFileDialog dlgOpen = new OpenFileDialog();&lt;br /&gt;
    if (dlgOpen.ShowDialog() == DialogResult.OK)&lt;br /&gt;
    {&lt;br /&gt;
      // use the File class to return info about the file&lt;br /&gt;
      string s = dlgOpen.FileName;&lt;br /&gt;
      Console.WriteLine(&amp;quot;Filename &amp;quot; + s);&lt;br /&gt;
      Console.WriteLine(&amp;quot; Created at &amp;quot; + File.GetCreationTime(s));&lt;br /&gt;
      Console.WriteLine(&amp;quot; Accessed at &amp;quot; + &lt;br /&gt;
       File.GetLastAccessTime(s));&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==illustrates the FileAttributes enumeration==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Mastering Visual C# .NET&lt;br /&gt;
by Jason Price, Mike Gunderloy&lt;br /&gt;
Publisher: Sybex;&lt;br /&gt;
ISBN: 0782129110&lt;br /&gt;
*/&lt;br /&gt;
 /*&lt;br /&gt;
  Example15_4.cs illustrates the FileAttributes enumeration&lt;br /&gt;
*/&lt;br /&gt;
using System;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
using System.IO;&lt;br /&gt;
public class Example15_4 &lt;br /&gt;
{&lt;br /&gt;
  // the DecipherAttributes method turns file attributes&lt;br /&gt;
  // into something easier for people to read&lt;br /&gt;
  public static void DecipherAttributes(FileAttributes f) &lt;br /&gt;
  {&lt;br /&gt;
    if ((f &amp;amp; FileAttributes.Archive) == FileAttributes.Archive)&lt;br /&gt;
      Console.WriteLine(&amp;quot;Archive&amp;quot;);&lt;br /&gt;
    if ((f &amp;amp; FileAttributes.rupressed) == FileAttributes.rupressed)&lt;br /&gt;
      Console.WriteLine(&amp;quot;Compressed&amp;quot;);&lt;br /&gt;
    if ((f &amp;amp; FileAttributes.Device) == FileAttributes.Device)&lt;br /&gt;
      Console.WriteLine(&amp;quot;Device&amp;quot;);&lt;br /&gt;
    if ((f &amp;amp; FileAttributes.Directory)   == FileAttributes.Directory)&lt;br /&gt;
      Console.WriteLine(&amp;quot;Directory&amp;quot;);&lt;br /&gt;
    if ((f &amp;amp; FileAttributes.Encrypted)  == FileAttributes.Encrypted)&lt;br /&gt;
      Console.WriteLine(&amp;quot;Encrypted&amp;quot;);&lt;br /&gt;
    if ((f &amp;amp; FileAttributes.Hidden)  == FileAttributes.Hidden)&lt;br /&gt;
      Console.WriteLine(&amp;quot;Hidden&amp;quot;);&lt;br /&gt;
    if ((f &amp;amp; FileAttributes.NotContentIndexed)  == FileAttributes.NotContentIndexed)&lt;br /&gt;
      Console.WriteLine(&amp;quot;NotContentIndexed&amp;quot;);&lt;br /&gt;
    if ((f &amp;amp; FileAttributes.Offline)  == FileAttributes.Offline)&lt;br /&gt;
      Console.WriteLine(&amp;quot;Offline&amp;quot;);&lt;br /&gt;
    if ((f &amp;amp; FileAttributes.ReadOnly)  == FileAttributes.ReadOnly)&lt;br /&gt;
      Console.WriteLine(&amp;quot;ReadOnly&amp;quot;);&lt;br /&gt;
    if ((f &amp;amp; FileAttributes.ReparsePoint)  == FileAttributes.ReparsePoint)&lt;br /&gt;
      Console.WriteLine(&amp;quot;ReparsePoint&amp;quot;);&lt;br /&gt;
    if ((f &amp;amp; FileAttributes.SparseFile)  == FileAttributes.SparseFile)&lt;br /&gt;
      Console.WriteLine(&amp;quot;SparseFile&amp;quot;);&lt;br /&gt;
    if ((f &amp;amp; FileAttributes.System)  == FileAttributes.System)&lt;br /&gt;
      Console.WriteLine(&amp;quot;System&amp;quot;);&lt;br /&gt;
    if ((f &amp;amp; FileAttributes.Temporary)  == FileAttributes.Temporary)&lt;br /&gt;
      Console.WriteLine(&amp;quot;Temporary&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
    &lt;br /&gt;
    [STAThread]&lt;br /&gt;
  public static void Main() &lt;br /&gt;
  {&lt;br /&gt;
    // create and show an open file dialog&lt;br /&gt;
    OpenFileDialog dlgOpen = new OpenFileDialog();&lt;br /&gt;
    if (dlgOpen.ShowDialog() == DialogResult.OK)&lt;br /&gt;
    {&lt;br /&gt;
      // retrieve and show the file attributes&lt;br /&gt;
      FileAttributes f = File.GetAttributes(dlgOpen.FileName);&lt;br /&gt;
      Console.WriteLine(&amp;quot;Filename &amp;quot; + dlgOpen.FileName +&lt;br /&gt;
        &amp;quot; has attributes:&amp;quot;);&lt;br /&gt;
      DecipherAttributes(f);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==illustrates the FileInfo class==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Mastering Visual C# .NET&lt;br /&gt;
by Jason Price, Mike Gunderloy&lt;br /&gt;
Publisher: Sybex;&lt;br /&gt;
ISBN: 0782129110&lt;br /&gt;
*/&lt;br /&gt;
 /*&lt;br /&gt;
  Example15_5.cs illustrates the FileInfo class&lt;br /&gt;
*/&lt;br /&gt;
using System;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
using System.IO;&lt;br /&gt;
public class Example15_5 &lt;br /&gt;
{&lt;br /&gt;
    &lt;br /&gt;
    [STAThread]&lt;br /&gt;
  public static void Main() &lt;br /&gt;
  {&lt;br /&gt;
    // create and show an open file dialog&lt;br /&gt;
    OpenFileDialog dlgOpen = new OpenFileDialog();&lt;br /&gt;
    if (dlgOpen.ShowDialog() == DialogResult.OK)&lt;br /&gt;
    {&lt;br /&gt;
      // use the File class to return info about the file&lt;br /&gt;
      FileInfo fi = new FileInfo(dlgOpen.FileName);&lt;br /&gt;
      Console.WriteLine(&amp;quot;Filename &amp;quot; + fi.FullName );&lt;br /&gt;
      Console.WriteLine(&amp;quot; Created at &amp;quot; + fi.CreationTime );&lt;br /&gt;
      Console.WriteLine(&amp;quot; Accessed at &amp;quot; + fi.LastAccessTime );&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==illustrates the FileSystemWatcher class==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Mastering Visual C# .NET&lt;br /&gt;
by Jason Price, Mike Gunderloy&lt;br /&gt;
Publisher: Sybex;&lt;br /&gt;
ISBN: 0782129110&lt;br /&gt;
*/&lt;br /&gt;
 /*&lt;br /&gt;
  Example15_9.cs illustrates the FileSystemWatcher class&lt;br /&gt;
*/&lt;br /&gt;
using System;&lt;br /&gt;
using System.IO;&lt;br /&gt;
public class Example15_9 &lt;br /&gt;
{&lt;br /&gt;
  // event handler for file change&lt;br /&gt;
  public static void OnChanged(object source, FileSystemEventArgs e) &lt;br /&gt;
  {&lt;br /&gt;
    // dump info to the screen&lt;br /&gt;
    Console.WriteLine(&amp;quot;Change to &amp;quot; + e.FullPath + &amp;quot;: &amp;quot; +&lt;br /&gt;
     e.ChangeType);&lt;br /&gt;
  }&lt;br /&gt;
  public static void Main() &lt;br /&gt;
  {&lt;br /&gt;
    // create a watcher for the c: drive&lt;br /&gt;
    FileSystemWatcher fsw = new FileSystemWatcher(&amp;quot;c:\\&amp;quot;);&lt;br /&gt;
    fsw.IncludeSubdirectories = true;&lt;br /&gt;
    // hook up the event handler&lt;br /&gt;
    fsw.Changed += new FileSystemEventHandler(OnChanged);&lt;br /&gt;
    // turn on file watching&lt;br /&gt;
    fsw.EnableRaisingEvents = true;&lt;br /&gt;
    &lt;br /&gt;
    // And wait for the user to quit&lt;br /&gt;
    Console.WriteLine(&amp;quot;Press any key to exit&amp;quot;);&lt;br /&gt;
    int i = Console.Read();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Uses methods in the File class to check the status of a file==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
C# Programming Tips &amp;amp; Techniques&lt;br /&gt;
by Charles Wright, Kris Jamsa&lt;br /&gt;
Publisher: Osborne/McGraw-Hill (December 28, 2001)&lt;br /&gt;
ISBN: 0072193794&lt;br /&gt;
*/&lt;br /&gt;
// Status.cs -- Uses methods in the File class to check the status of a file.&lt;br /&gt;
//&lt;br /&gt;
//              Compile this program with the following command line&lt;br /&gt;
//                  C:&amp;gt;csc Status.cs&lt;br /&gt;
using System;&lt;br /&gt;
using System.IO;&lt;br /&gt;
namespace nsStreams&lt;br /&gt;
{&lt;br /&gt;
    public class Status&lt;br /&gt;
    {&lt;br /&gt;
        static public void Main (string [] args)&lt;br /&gt;
        {&lt;br /&gt;
            if (args.Length == 0)&lt;br /&gt;
            {&lt;br /&gt;
                Console.WriteLine (&amp;quot;Please enter a file name&amp;quot;);&lt;br /&gt;
                return;&lt;br /&gt;
            }&lt;br /&gt;
            if (!File.Exists (args[0]))&lt;br /&gt;
            {&lt;br /&gt;
                Console.WriteLine (args[0] + &amp;quot; does not exist&amp;quot;);&lt;br /&gt;
                return;&lt;br /&gt;
            }&lt;br /&gt;
            DateTime created = File.GetCreationTime (args[0]);&lt;br /&gt;
            DateTime accessed = File.GetLastAccessTime (args[0]);&lt;br /&gt;
            DateTime written = File.GetLastWriteTime (args[0]);&lt;br /&gt;
            Console.WriteLine (&amp;quot;File &amp;quot; + args[0] + &amp;quot;:&amp;quot;);&lt;br /&gt;
            string str = created.ToString();&lt;br /&gt;
            int index = str.IndexOf (&amp;quot; &amp;quot;);&lt;br /&gt;
            Console.WriteLine (&amp;quot;\tCreated on &amp;quot; + str.Substring (0, index) + &amp;quot; at &amp;quot; + str.Substring (index + 1));&lt;br /&gt;
            str = accessed.ToString();&lt;br /&gt;
            index = str.IndexOf (&amp;quot; &amp;quot;);&lt;br /&gt;
            Console.WriteLine (&amp;quot;\tLast accessed on &amp;quot; + str.Substring (0, index) + &amp;quot; at &amp;quot; + str.Substring (index + 1));&lt;br /&gt;
            str = written.ToString();&lt;br /&gt;
            index = str.IndexOf (&amp;quot; &amp;quot;);&lt;br /&gt;
            Console.WriteLine (&amp;quot;\tLast written on &amp;quot; + str.Substring (0, index) + &amp;quot; at &amp;quot; + str.Substring (index + 1));&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Uses methods in the File class to check whether a file exists==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
C# Programming Tips &amp;amp; Techniques&lt;br /&gt;
by Charles Wright, Kris Jamsa&lt;br /&gt;
Publisher: Osborne/McGraw-Hill (December 28, 2001)&lt;br /&gt;
ISBN: 0072193794&lt;br /&gt;
*/&lt;br /&gt;
// Exists.cs -- Uses methods in the File class to dheck whether a file exists.&lt;br /&gt;
//              If it exists, it then opens and reads the file to the console.&lt;br /&gt;
//&lt;br /&gt;
//              Compile this program with the following command line&lt;br /&gt;
//                  C:&amp;gt;csc Exists.cs&lt;br /&gt;
using System;&lt;br /&gt;
using System.IO;&lt;br /&gt;
namespace nsStreams&lt;br /&gt;
{&lt;br /&gt;
    public class Exists&lt;br /&gt;
    {&lt;br /&gt;
        static public void Main (string [] args)&lt;br /&gt;
        {&lt;br /&gt;
            if (args.Length == 0)&lt;br /&gt;
            {&lt;br /&gt;
                Console.WriteLine (&amp;quot;Please enter a file name&amp;quot;);&lt;br /&gt;
                return;&lt;br /&gt;
            }&lt;br /&gt;
            if (!File.Exists (args[0]))&lt;br /&gt;
            {&lt;br /&gt;
                Console.WriteLine (args[0] + &amp;quot; does not exist&amp;quot;);&lt;br /&gt;
                return;&lt;br /&gt;
            }&lt;br /&gt;
            StreamReader reader;&lt;br /&gt;
            try&lt;br /&gt;
            {&lt;br /&gt;
                reader = File.OpenText (args[0]);&lt;br /&gt;
            }&lt;br /&gt;
            catch (Exception e)&lt;br /&gt;
            {&lt;br /&gt;
                Console.WriteLine (e.Message);&lt;br /&gt;
                Console.WriteLine (&amp;quot;Cannot open &amp;quot; + args[0]);&lt;br /&gt;
                return;&lt;br /&gt;
            }&lt;br /&gt;
            while (reader.Peek() &amp;gt;= 0)&lt;br /&gt;
            {&lt;br /&gt;
                Console.WriteLine (reader.ReadLine ());&lt;br /&gt;
            }&lt;br /&gt;
            reader.Close ();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>