th)? path:" " + path;
}
void DeleteFile (string fileName)
{(! _ userRights.CanCreate ()) new FileSystemAccessDeniedException ();
filePath=Path.Combine (CheckAndGetCurrentDirectory (), fileName.TrimStart (new [] { laquo ;, /})); (! File.Exists (filePath)) new FileSystemAccessDeniedException ();
{. Delete (filePath);
} (IOException ex)
{new FileSystemException (ex.Message.Replace (_rootDirectory, ));
}
}
void RenameFile (string fileName, string newFileName)
{(! _ userRights.CanCreate ()) new FileSystemAccessDeniedException ();
oldFilePath=Path.Combine (CheckAndGetCurrentDirectory (), fileName.TrimStart (new [] { laquo ;, /})); (! File.Exists (oldFilePath)) new FileSystemAccessDeniedException ();
newFilePath=Path.Combine (CheckAndGetCurrentDirectory (), newFileName.TrimStart (new [] { laquo ;, /})); (File.Exists (newFilePath)) new FileSystemException (string.Format ( File " {0} " already exists raquo ;, newFileName));
{. Move (oldFilePath, newFilePath);
} (IOException ex)
{new FileSystemException (ex.Message.Replace (_rootDirectory, ));
}
}
string BeginWriteFile (string fileName, bool newNameIfExists=false)
{(_ savingFile!=null) new Exception ( Previous file not saved );
(! _ userRights.CanUpload ()) new FileSystemAccessDeniedException ();
filePath=Path.Combine (CheckAndGetCurrentDirectory (), fileName.TrimStart (new [] { laquo ;, /})); (File.Exists (filePath) || string.IsNullOrWhiteSpace (fileName))
{(! newNameIfExists) new FileSystemAccessDeniedException ();
=Guid.NewGuid (). ToString (). Substring (0, 8);=Path.Combine (CheckAndGetCurrentDirectory (), fileName.TrimStart (new [] { laquo ;, raquo ;/}));
}
_ savingFile=new FileStream (filePath, FileMode.CreateNew, FileAccess.Write, FileShare.None, BufferSize, .SequentialScan);
fileName;
}
void WriteData (byte [] data, int size)
{(_ savingFile == null ||! _savingFile.CanWrite) new Exception ( File not accessible to write );
_ savingFile.Write (data, 0, size);
}
void EndWriteFile ()
{(_ savingFile == null) new Exception ( File not opened );
_ savingFile.Close ();
_ savingFile=null;
}
void BeginReadFile (string fileName)
{(_ readingFile!=null) new Exception ( Previous file not closed );
(! _ userRights.CanDownload ()) new FileSystemAccessDeniedException ();
filePath=Path.Combine (CheckAndGetCurrentDirectory (), fileName.TrimStart (new [] { laquo ;, /})); (! File.Exists (filePath)) new FileSystemAccessDeniedException ();
_ readingFile=new FileStream (filePath, FileMode.Open, FileAccess.Read, FileShare.Read, BufferSize, .SequentialScan);
}
int ReadData (byte [] buffer, int size)
{(_ readingFile == null ||! _readingFile.CanRead) new Exception ( File not accessible to read );
_ readingFile.Read (buffer, 0, size);
} void EndReadFile ()
{(_ readingFile == null) new Exception ( File not opened );
_ readingFile.Close ();
_ readingFile=null;
}
bool FileExists (string fileName)
{File.Exists (Path.Combine (CheckAndGetCurrentDirectory (), fileName.TrimStart (new [] { laquo ;, /})));
}
bool CanRenameFile ()
{_ userRights.CanCreate ();
}
bool CanUploadFile ()
{_ userRights.CanUpload ();
}
bool CanDownloadFile ()
{_ userRights.CanDownload ();
} DateTime GetFileModifiedDate (string fileName)
{(! _ userRights.CanDownload ()) new FileSystemAccessDeniedException ();
...