Class File
- Namespace
- Kentico.Xperience.AmazonStorage
- Assembly
- Kentico.Xperience.AmazonStorage.dll
Implementation of File class for Amazon S3.
public class File : AbstractFile
- Inheritance
-
objectFile
- Extension Methods
Constructors
File()
Initializes a new instance of the File class, which provides operations with files.
public File()
Properties
Provider
Get or set S3ObjectInfoProvider.
public static IS3ObjectInfoProvider Provider { get; set; }
Property Value
Methods
AppendAllText(string, string)
Opens a file, appends the specified string to the file, and then closes the file. If the file does not exist, this method creates a file, writes the specified string to the file, then closes the file.
public override void AppendAllText(string path, string contents)
Parameters
pathstringPath
contentsstringContent to write.
AppendAllText(string, string, Encoding)
Opens a file, appends the specified string to the file, and then closes the file. If the file does not exist, this method creates a file, writes the specified string to the file, then closes the file.
public override void AppendAllText(string path, string contents, Encoding encoding)
Parameters
pathstringPath
contentsstringContent to write.
encodingEncodingThe character encoding to use
Copy(string, string)
Copies an existing file to a new file. Overwriting a file of the same name is not allowed.
public override void Copy(string sourceFileName, string destFileName)
Parameters
sourceFileNamestringPath to source file.
destFileNamestringPath to destination file.
Copy(string, string, bool)
Copies an existing file to a new file. Overwriting a file of the same name is allowed.
public override void Copy(string sourceFileName, string destFileName, bool overwrite)
Parameters
sourceFileNamestringPath to source file.
destFileNamestringPath to destination file.
overwriteboolIf destination file should be overwritten.
Create(string)
Creates or overwrites a file in the specified path.
public override FileStream Create(string path)
Parameters
pathstringPath to file.
Returns
CreateText(string)
Creates or opens a file for writing UTF-8 encoded text.
public override StreamWriter CreateText(string path)
Parameters
pathstringPath to file.
Returns
Delete(string)
Deletes the specified file. An exception is not thrown if the specified file does not exist.
public override void Delete(string path)
Parameters
pathstringPath to file
Exists(string)
Determines whether the specified file exists.
public override bool Exists(string path)
Parameters
pathstringPath to file.
Returns
- bool
ExistsInFileSystem(string)
Returns whether given file exist in file system.
protected virtual bool ExistsInFileSystem(string path)
Parameters
pathstringPath to given file.
Returns
- bool
GetFileStream(string, FileMode)
Returns new instance of FileStream class.
protected virtual FileStream GetFileStream(string path, FileMode mode)
Parameters
pathstringPath.
modeFileModeFile mode.
Returns
GetFileStream(string, FileMode, FileAccess)
Returns new instance of FileStream class.
protected virtual FileStream GetFileStream(string path, FileMode mode, FileAccess access)
Parameters
pathstringPath.
modeFileModeFile mode.
accessFileAccessFile access.
Returns
GetFileUrl(string)
Returns URL to file. If can be accessed directly then direct URL is generated else URL with GetFile page is generated.
[Obsolete("Method is obsolete and will be removed in future versions.")]
public override string GetFileUrl(string path)
Parameters
pathstringVirtual path starting with ~ or absolute path.
Returns
- string
GetHashString(string)
Returns Hashed string from specified query string. Hashed string is not user specific.
protected virtual string GetHashString(string query)
Parameters
querystringQuery to hash.
Returns
- string
GetLastWriteTime(string)
Returns the date and time the specified file or directory was last written to.
public override DateTime GetLastWriteTime(string path)
Parameters
pathstringPath to file.
Returns
- DateTime
Move(string, string)
Moves a specified file to a new location, providing the option to specify a new file name.
public override void Move(string sourceFileName, string destFileName)
Parameters
sourceFileNamestringSource file name.
destFileNamestringDestination file name.
Open(string, FileMode, FileAccess)
Opens a FileStream on the specified path, with the specified mode and access.
public override FileStream Open(string path, FileMode mode, FileAccess access)
Parameters
pathstringPath to file.
modeFileModeFile mode.
accessFileAccessFile access.
Returns
OpenRead(string)
Opens an existing file for reading.
public override FileStream OpenRead(string path)
Parameters
pathstringPath to file.
Returns
OpenText(string)
Opens an existing UTF-8 encoded text file for reading.
public override StreamReader OpenText(string path)
Parameters
pathstringPath to file
Returns
ReadAllBytes(string)
Opens a binary file, reads the contents of the file into a byte array, and then closes the file.
public override byte[] ReadAllBytes(string path)
Parameters
pathstringPath to file.
Returns
- byte[]
ReadAllText(string)
Opens a text file, reads all lines of the file, and then closes the file.
public override string ReadAllText(string path)
Parameters
pathstringPath to file.
Returns
- string
ReadAllText(string, Encoding)
Opens a text file, reads all lines of the file, and then closes the file.
public override string ReadAllText(string path, Encoding encoding)
Parameters
pathstringPath to file
encodingEncodingThe character encoding to use
Returns
- string
SetAttributes(string, FileAttributes)
Sets the specified FileAttributes of the file on the specified path.
public override void SetAttributes(string path, FileAttributes fileAttributes)
Parameters
pathstringPath to file.
fileAttributesFileAttributesFile attributes.
SetLastWriteTime(string, DateTime)
Sets the date and time that the specified file was last written to.
public override void SetLastWriteTime(string path, DateTime lastWriteTime)
Parameters
pathstringPath to file.
lastWriteTimeDateTimeLast write time.
WriteAllBytes(string, byte[])
Creates a new file, writes the specified byte array to the file, and then closes the file. If the target file already exists, it is overwritten.
public override void WriteAllBytes(string path, byte[] bytes)
Parameters
pathstringPath to file.
bytesbyte[]Bytes to write.
WriteAllText(string, string)
Creates a new file, write the contents to the file, and then closes the file. If the target file already exists, it is overwritten.
public override void WriteAllText(string path, string contents)
Parameters
pathstringPath to file
contentsstringContent to write.
WriteAllText(string, string, Encoding)
Creates a new file, write the contents to the file, and then closes the file. If the target file already exists, it is overwritten.
public override void WriteAllText(string path, string contents, Encoding encoding)
Parameters
pathstringPath to file
contentsstringContent to write
encodingEncodingThe character encoding to use