FileInfo

FileInfo class

Represents a path to a file and a file referred to by this path and provides methods for manipulating it. Objects of this class should only be allocated using System::MakeObject() function. Never create instance of this type on stack or using operator new, as it will result in runtime errors and/or assertion faults. Always wrap this class into System::SmartPtr pointer and use this pointer to pass it to functions as argument.

class FileInfo : public System::IO::FileSystemInfo

Methods

MethodDescription
StreamWriterPtr AppendText()Opens a file represented by the current object for writing text using UTF-8 encoding, in ‘Append’ mode with no sharing.
FileInfoPtr CopyTo(const String&)Copies the file represented by the current object to the specified location. If the destination file already exists, the copying fails.
FileInfoPtr CopyTo(const String&, bool)Copies the file represented by the current object to the specified location. A parameter specifies if existing destination file should be overwritten.
FileStreamPtr Create()Creates a file at the location specified by the path represented by the current object and opens it for reading and writing, in truncate mode and with no sharing.
StreamWriterPtr CreateText()Creates a file at the location specified by the path represented by the current object and opens it for writing text using UTF-8 encoding with no sharing.
void Decrypt()NOT IMPLEMENTED.
void Delete() overrideRemoves the file represented by the current object.
void Encrypt()NOT IMPLEMENTED.
virtual bool Equals(ptr)Compares objects using C# Object.Equals semantics.
static std::enable_if<IsSmartPtr<T1>::value&&IsSmartPtr<T2>::value, bool>::type Equals(T1 const&, T2 const&)Compares reference type objects in C# style.
static std::enable_if<!IsSmartPtr<T1>::value&&!IsSmartPtr<T2>::value, bool>::type Equals(T1 const&, T2 const&)Compares value type objects in C# style.
static bool Equals(float const&, float const&)Emulates C#-style floating point comparison where two NaNs are considered equal even though according to IEC 60559:1989 NaN is not equal to any value, including NaN.
static bool Equals(double const&, double const&)Emulates C#-style floating point comparison where two NaNs are considered equal even though according to IEC 60559:1989 NaN is not equal to any value, including NaN.
virtual bool FastCast(const Details::FastRttiBase&, void **) constFor internal purposes only.
FileInfo(const String&)Constructs a new instance of FileInfo class that represents the specified file.
virtual void Finalize()Does nothing.
FileAttributes get_Attributes()Returns the attributes of the entity represented by the current object.
DateTime get_CreationTime()Returns the creation time of the entity represented by the current object as local time.
DateTime get_CreationTimeUtc()Returns the creation time of the entity represented by the current object as UTC time.
DirectoryInfoPtr get_Directory()Returns a DirectoryInfo object that represents a directory in which the file represented by the current object is located.
String get_DirectoryName()Returns the full name of the directory in which the file represented by the current object is loctaed.
bool get_Exists() overrideReturns a value that indicates if the file exists.
String get_Extension()Returns the extension of the file represented by the current object.
virtual String get_FullName()Returns the full name (including path) of the entity represented by the current object.
bool get_IsReadOnly()Returns a value that indicates if the ReadOnly attribute is set.
DateTime get_LastAccessTime()Returns the last access time of the entity represented by the current object as local time.
DateTime get_LastAccessTimeUtc()Returns the last access time of the entity represented by the current object as UTC time.
DateTime get_LastWriteTime()Returns the last write time of the entity represented by the current object as local time.
DateTime get_LastWriteTimeUtc()Returns the last write time of the entity represented by the current object as UTC time.
int64_t get_Length()Returns the size of the file in bytes.
String get_Name() overrideReturns the name of the file.
Detail::SmartPtrCounter * GetCounter()Gets reference counter data structure associated with the object.
virtual int32_t GetHashCode() constAnalog of C# Object.GetHashCode() method. Enables hashing of custom objects.
virtual const TypeInfo& GetType() constGets actual type of object. Analog of C# System.Object.GetType() call.
virtual bool Is(const TypeInfo&) constCheck if object represents an instance of type described by targetType. Analog of C# ‘is’ operator.
void Lock()Implements C# lock() statement locking. Call directly or use LockContext sentry object.
virtual ptr MemberwiseClone() constAnalog of C# Object.MemberwiseClone() method. Enables cloning custom types.
void MoveTo(const String&)Moves the file represented by the current object to the specified location.
Object()Creates object. Initializes all internal data structures.
Object(Object const&)Copy constructor. Doesn’t copy anything, really, just initializes new object and enables copy constructing subclasses.
FileStreamPtr Open(FileMode)Opens the file represented by the current object in the specified mode for reading and writing and with no sharing.
FileStreamPtr Open(FileMode, FileAccess)Opens the file represented by the current object in the specified mode, with the specified access type and with no sharing.
FileStreamPtr Open(FileMode, FileAccess, FileShare)Opens the file represented by the current object in the specified mode, with the specified access type and sharing option.
FileStreamPtr OpenRead()Opens a file represented by the current object for reading only, in ‘Open’ mode with shared access for reading.
StreamReaderPtr OpenText()Opens the existing file at the location specified by the path represented by the current object for reading text using UTF-8 encoding with no sharing.
FileStreamPtr OpenWrite()Opens a file represented by the current object for writing only, in ‘OpenOrCreate’ mode with no sharing.
Object& operator=(Object const&)Assignment operator. Doesn’t copy anything, really, just initializes new object and enables copy constructing subclasses.
static bool ReferenceEquals(ptr const&, ptr const&)Compares objects by reference.
static std::enable_if<!IsSmartPtr<T>::value, bool>::type ReferenceEquals(T const&, T const&)Compares objects by reference.
static std::enable_if<!IsSmartPtr<T>::value, bool>::type ReferenceEquals(T const&, std::nullptr_t)Reference-compares value type object with nullptr.
bool ReferenceEquals(String const&, std::nullptr_t)Specialization of Object::ReferenceEquals for case of string and nullptr.
bool ReferenceEquals(String const&, String const&)Specialization of Object::ReferenceEquals for case of strings.
void Refresh()Refreshes the state of the current object.
int RemovedSharedRefs(int)Decreases shared reference count by specified value.
FileInfoPtr Replace(const String&, const String&)Replaces the contents of a specified destination file with the file represented by the current FileInfo object and creates a backup of the replaced file.
FileInfoPtr Replace(const String&, const String&, bool)Replaces the contents of a specified destination file with the file represented by the current FileInfo object and creates a backup of the replaced file.
void set_Attributes(FileAttributes)Sets the specified attributes on the entity represeted by the current object.
void set_CreationTime(DateTime)Sets the creation time of the entity represented by the current object as local time.
void set_CreationTimeUtc(DateTime)Sets the creation time of the entity represented by the current object as UTC time.
void set_IsReadOnly(bool)Sets or unsets the ReadOnly attribute on the file.
void set_LastAccessTime(DateTime)Sets the last access time of the entity represented by the current object as local time.
void set_LastAccessTimeUtc(DateTime)Sets the last access time of the entity represented by the current object as UTC time.
void set_LastWriteTime(DateTime)Sets the last write time of the entity represented by the current object as local time.
void set_LastWriteTimeUtc(DateTime)Sets the last write time of the entity represented by the current object as UTC time.
virtual void SetTemplateWeakPtr(uint32_t)Set n’th template argument a weak pointer (rather than shared). Allows switching pointers in containers to weak mode.
int SharedCount() constGets current value of shared reference counter.
Object * SharedRefAdded()Increments shared reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector.
int SharedRefRemovedSafe()Decrements and returns shared reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector.
String ToString() const overrideReturns a path represented by the current object.
static const TypeInfo& Type()Implements C# typeof(System.Object) construct.
void Unlock()Implements C# lock() statement unlocking. Call directly or use LockContext sentry object.
Detail::SmartPtrCounter * WeakRefAdded()Increments weak reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector.
void WeakRefRemoved()Decrements weak reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector.
virtual ~Object()Destroys object. Frees all internal data structures.

See Also