2 using System.Collections;
3 using System.Collections.Generic;
6 using System.Xml.Serialization;
9 namespace Seci.Definitions
30 public String FileLocation {
get {
return _fileLocation; } set { _fileLocation = value; } }
31 public Byte[] FileData {
get {
return _fileData; } set { _fileData = value; } }
32 [XmlIgnore]
public String OwningComponent {
get {
return _owningComponent; } set { _owningComponent = value; } }
47 _fileLocation = fileName;
59 FileInfo fInfo =
new FileInfo(_fileLocation);
61 Int64 numBytes = fInfo.Length;
63 FileStream fStream =
new FileStream(_fileLocation, FileMode.Open, FileAccess.Read);
65 BinaryReader br =
new BinaryReader(fStream);
67 Byte[] data = br.ReadBytes((int)numBytes);
95 if (_fileLocation != null && _fileData != null && _fileData.Length > 0)
98 FileInfo fOld =
new FileInfo(_fileLocation);
101 fOld.CopyTo(_fileLocation +
".bak",
true);
105 FileStream fStream =
new FileStream(_fileLocation, FileMode.Create, FileAccess.Write);
106 BinaryWriter bw =
new BinaryWriter(fStream);
115 throw new ArgumentException(e.Message);
129 updateModifiedTime();
140 FileInfo fOrig =
new FileInfo(_fileLocation);
143 fOrig.CopyTo(_fileLocation +
".orig",
true);
159 FileInfo fOrig =
new FileInfo(_fileLocation +
".orig");
162 fOrig.CopyTo(_fileLocation,
true);
178 _lastModifiedTime = getLastModifiedDateTime();
194 DateTime lastMod = getLastModifiedDateTime();
195 if (lastMod > _lastModifiedTime)
214 FileInfo fInfo =
new FileInfo(_fileLocation);
218 throw new Exception(
"File does not exist!");
221 return fInfo.LastWriteTime;
AssociatedFile(String fileName)
Recommended constructor for use in code.
void CreateOriginal()
Creates a copy of the file but with the .orig extension
void updateModifiedTime()
Method for updating the last modified time.
DateTime _lastModifiedTime
Boolean ConvertFileToByteArray()
Method for converting a file to a byte array.
Boolean HasBeenModified()
Method for checking whether the file was modified.
void CreateFile()
Method for creating a file from the saved byte array. Will back-up the existing version of the file a...
This class is used for storing files as part of a configuration. Typically, the files stored are ini ...
AssociatedFile()
Default constructor
DateTime getLastModifiedDateTime()
Method for getting the last time when the file was modified.
void RestoreOriginal()
Restores the on disk copy of the associated file to what was originally in the configuration. In other words, it overwrites the file with the .orig file.