1 //------------------------------------------------------------------------------
\r
3 // System.IO.File.cs
\r
5 // Copyright (C) 2001 Moonlight Enterprises, All Rights Reserved
\r
7 // Author: Jim Richardson, develop@wtfo-guru.com
\r
8 // Created: Monday, August 22, 2001
\r
10 // TODO: Research exceptions for all methods
\r
11 //------------------------------------------------------------------------------
\r
20 public sealed class File : Object
\r
23 /// Creates a StreamWriter that appends text to a file creating the file if needed
\r
26 public static StreamWriter AppendText(string path)
\r
27 { // TODO: Implement
\r
32 /// Copies a file overwriting existing if necessary
\r
34 public static void Copy(string sourceFilename, string destFilename)
\r
36 Copy(sourceFilename, destFilename, true);
\r
40 /// Copies a file overwriting existing if specified
\r
43 public static void Copy(string sourceFilename, string destFilename, bool bOverwrite)
\r
44 { // TODO: Implement
\r
48 /// Creates a file given the fully qualified path
\r
51 public static FileStream Create(string path)
\r
52 { // TODO: Research default buffersize
\r
53 return Create(path, 1024);
\r
57 /// Creates a file given the fully qualified path using specified buffersize
\r
60 public static FileStream Create(string path, int buffersize)
\r
61 { // TODO: Implement
\r
69 public static void Delete(string path)
\r
70 { // TODO: Implement
\r
74 /// Returns true if file exists on disk
\r
77 public static bool Exists(string path)
\r
78 { // TODO: Implement
\r
83 /// Returns the date and time the file specified by path was created
\r
85 public static FileAttributes GetAttributes(string path)
\r
87 FileInfo fInfo = new FileInfo(path);
\r
88 return fInfo.Attributes;
\r
92 /// Returns the date and time the directory specified by path was created
\r
94 public static DateTime GetCreationTime(string path)
\r
96 return getInfo(path).CreationTime;
\r
100 /// Returns the date and time the directory specified by path was last accessed
\r
102 public static DateTime GetLastAccessTime(string path)
\r
104 return getInfo(path).LastAccessTime;
\r
108 /// Returns the date and time the directory specified by path was last modified
\r
110 public static DateTime GetLastWriteTime(string path)
\r
112 return getInfo(path).LastWriteTime;
\r
118 public static void Move(string srcFilename, string destFilename)
\r
120 getInfo(srcFilename).MoveTo(destFilename);
\r
124 /// Open a file for exclusive reading and writing
\r
127 public static FileStream Open(string path, FileMode mode)
\r
128 { // TODO: research if exclusive is the correct default
\r
129 return getInfo(path).Open(mode, FileAccess.ReadWrite);
\r
133 /// Open a file for exclusive access specified by mode
\r
136 public static FileStream Open(string path, FileMode mode, FileAccess access)
\r
137 { // TODO: research if exclusive is the correct default
\r
138 return getInfo(path).Open(mode, access, FileShare.None);
\r
142 /// Open a file access specified by mode, sharing specified by share
\r
144 public static FileStream Open(string path, FileMode mode, FileAccess access, FileShare share)
\r
146 return getInfo(path).Open(mode, access, share);
\r
150 /// Open a FileStream for reading and writing
\r
153 public static FileStream OpenRead(string path)
\r
154 { // TODO: find out what default share should be
\r
155 return getInfo(path).OpenRead();
\r
159 /// Open a StreamReader
\r
161 public static StreamReader OpenText(string path)
\r
163 return getInfo(path).OpenText();
\r
167 /// Open a FileStream for reading and writing
\r
169 public FileStream OpenWrite(string path)
\r
171 return getInfo(path).OpenWrite();
\r
175 /// Sets the attributes of file specified by path
\r
177 public static void SetAttributes(string path, FileAttributes attributes)
\r
179 getInfo(path).Attributes = attributes;
\r
183 /// Sets the creation time of the directory specified by path
\r
185 public static void SetCreationTime(string path, DateTime creationTime)
\r
187 getInfo(path).CreationTime = creationTime;
\r
191 /// Sets the last access time of the directory specified by path
\r
193 public static void SetLastAccessTime(string path, DateTime accessTime)
\r
195 getInfo(path).LastAccessTime = accessTime;
\r
199 /// Sets the last write time of the directory specified by path
\r
201 public static void SetLastWriteTime(string path, DateTime modifiedTime)
\r
203 getInfo(path).LastWriteTime = modifiedTime;
\r
206 private static FileInfo getInfo(string path)
\r
208 return new FileInfo(path);
\r