//------------------------------------------------------------------------------
//
// System.IO.File.cs
//
// Copyright (C) 2001 Moonlight Enterprises, All Rights Reserved
//
// Author: Jim Richardson, develop@wtfo-guru.com
// Created: Monday, August 22, 2001
//
// TODO: Research exceptions for all methods
//------------------------------------------------------------------------------
using System;
namespace System.IO
{
///
///
///
public sealed class File : Object
{
///
/// Creates a StreamWriter that appends text to a file creating the file if needed
///
[MonoTODO]
public static StreamWriter AppendText(string path)
{ // TODO: Implement
return null;
}
///
/// Copies a file overwriting existing if necessary
///
public static void Copy(string sourceFilename, string destFilename)
{
Copy(sourceFilename, destFilename, true);
}
///
/// Copies a file overwriting existing if specified
///
[MonoTODO]
public static void Copy(string sourceFilename, string destFilename, bool bOverwrite)
{ // TODO: Implement
}
///
/// Creates a file given the fully qualified path
///
[MonoTODO]
public static FileStream Create(string path)
{ // TODO: Research default buffersize
return Create(path, 1024);
}
///
/// Creates a file given the fully qualified path using specified buffersize
///
[MonoTODO]
public static FileStream Create(string path, int buffersize)
{ // TODO: Implement
return null;
}
///
/// Delete a file
///
[MonoTODO]
public static void Delete(string path)
{ // TODO: Implement
}
///
/// Returns true if file exists on disk
///
[MonoTODO]
public static bool Exists(string path)
{ // TODO: Implement
return false;
}
///
/// Returns the date and time the file specified by path was created
///
public static FileAttributes GetAttributes(string path)
{
FileInfo fInfo = new FileInfo(path);
return fInfo.Attributes;
}
///
/// Returns the date and time the directory specified by path was created
///
public static DateTime GetCreationTime(string path)
{
return getInfo(path).CreationTime;
}
///
/// Returns the date and time the directory specified by path was last accessed
///
public static DateTime GetLastAccessTime(string path)
{
return getInfo(path).LastAccessTime;
}
///
/// Returns the date and time the directory specified by path was last modified
///
public static DateTime GetLastWriteTime(string path)
{
return getInfo(path).LastWriteTime;
}
///
/// Moves a file
///
public static void Move(string srcFilename, string destFilename)
{
getInfo(srcFilename).MoveTo(destFilename);
}
///
/// Open a file for exclusive reading and writing
///
[MonoTODO]
public static FileStream Open(string path, FileMode mode)
{ // TODO: research if exclusive is the correct default
return getInfo(path).Open(mode, FileAccess.ReadWrite);
}
///
/// Open a file for exclusive access specified by mode
///
[MonoTODO]
public static FileStream Open(string path, FileMode mode, FileAccess access)
{ // TODO: research if exclusive is the correct default
return getInfo(path).Open(mode, access, FileShare.None);
}
///
/// Open a file access specified by mode, sharing specified by share
///
public static FileStream Open(string path, FileMode mode, FileAccess access, FileShare share)
{
return getInfo(path).Open(mode, access, share);
}
///
/// Open a FileStream for reading and writing
///
[MonoTODO]
public static FileStream OpenRead(string path)
{ // TODO: find out what default share should be
return getInfo(path).OpenRead();
}
///
/// Open a StreamReader
///
public static StreamReader OpenText(string path)
{
return getInfo(path).OpenText();
}
///
/// Open a FileStream for reading and writing
///
public FileStream OpenWrite(string path)
{
return getInfo(path).OpenWrite();
}
///
/// Sets the attributes of file specified by path
///
public static void SetAttributes(string path, FileAttributes attributes)
{
getInfo(path).Attributes = attributes;
}
///
/// Sets the creation time of the directory specified by path
///
public static void SetCreationTime(string path, DateTime creationTime)
{
getInfo(path).CreationTime = creationTime;
}
///
/// Sets the last access time of the directory specified by path
///
public static void SetLastAccessTime(string path, DateTime accessTime)
{
getInfo(path).LastAccessTime = accessTime;
}
///
/// Sets the last write time of the directory specified by path
///
public static void SetLastWriteTime(string path, DateTime modifiedTime)
{
getInfo(path).LastWriteTime = modifiedTime;
}
private static FileInfo getInfo(string path)
{
return new FileInfo(path);
}
}
}