Table of Contents

Class FilesAndFolders

Namespace
Dynamicweb.Content.Files
Assembly
Dynamicweb.dll
This class contains the functions to handle whith files and folders.
[Obsolete("Do not use")]
public class FilesAndFolders
Inheritance
FilesAndFolders
Inherited Members

Methods

CopyFile(string, string)

Copy the current file to another location.
public static OperationReport CopyFile(string file, string destination)

Parameters

file string
Current file.
destination string
Another location.

Returns

OperationReport
Report.

CopyFileBrowser(string, string)

Copy the current file to another location.
public static OperationReport CopyFileBrowser(string file, string destination)

Parameters

file string
Current file.
destination string
Another location.

Returns

OperationReport
Report.

CopyFiles(string[], string)

Copy the current file to the destination file.
public static OperationReport CopyFiles(string[] files, string destinationFolder)

Parameters

files string[]
File to copy.
destinationFolder string
Where to copy.

Returns

OperationReport
Report.

Remarks

If operation is succeeded then calls the logger.

CopyFolder(string, string)

Copy current folder and all its subfolders and subfiles to another location with permissions.
public static OperationReport CopyFolder(string folder, string destination)

Parameters

folder string
destination string

Returns

OperationReport

CopyFolder(string, string, ref string)

Copy current folder and all its subfolders and subfiles to another location with permissions.
public static OperationReport CopyFolder(string folder, string destination, ref string resultingFolderPath)

Parameters

folder string
destination string
resultingFolderPath string
copyed folder path

Returns

OperationReport

CopyFolders(string, string)

[Obsolete("Use CopyFolder instead.")]
public static OperationReport CopyFolders(string folder, string destination)

Parameters

folder string
destination string

Returns

OperationReport

CopyFolders(string, string, ref string)

[Obsolete("Use CopyFolder instead.")]
public static OperationReport CopyFolders(string folder, string destination, ref string destFolderPath)

Parameters

folder string
destination string
destFolderPath string

Returns

OperationReport

CreateFile(string, bool)

Creates the new file.
public static OperationReport CreateFile(string file, bool template)

Parameters

file string
File to create.
template bool
Whether template can be inserted.

Returns

OperationReport
Report.

CreateFolder(string, string)

[Obsolete("Use MakeFolder instead.")]
public static OperationReport CreateFolder(string folder, string newfolder)

Parameters

folder string
newfolder string

Returns

OperationReport

DeleteFile(string)

Simply moves the current file to another location.
public static OperationReport DeleteFile(string file)

Parameters

file string
Phisical path to the current file.

Returns

OperationReport
Report.

DeleteFiles(string[])

Simply moves the current files of array to another location.
public static OperationReport DeleteFiles(string[] files)

Parameters

files string[]
Current array of files.

Returns

OperationReport
Report.

DeleteFolder(string)

Deletes the current folder.
[Obsolete("Use DeleteFolders instead")]
public static OperationReport DeleteFolder(string folder)

Parameters

folder string
Current folder.

Returns

OperationReport
Report.

Remarks

If operation is succeeded then calls the logger.

DeleteFolders(string)

Deletes current folder and all its subfolders and files.
public static OperationReport DeleteFolders(string folder)

Parameters

folder string

Returns

OperationReport

GetFileEncoding(string, ref Encoding)

Returns the file encoding.
public static string GetFileEncoding(string filePath, ref Encoding encoding)

Parameters

filePath string
The physical path and name of the file.
encoding Encoding
Reference to the encoding to set.

Returns

string

Remarks

Reads the first bytes of a file to determined the file encoding.

GetFilesFolderName()

Gets the name of the files folder. I.e "Filer" in /Files/Filer/
[Obsolete("Use 'Files' instead.")]
public static string GetFilesFolderName()

Returns

string

Remarks

Specified in GlobalSettings.aspx/config - /Globalsettings/System/Filesystem/FilesFolderName. Default value is "Filer"

GetFileSizeKb(double)

Converts bytes to KB string with 2 decimals for UI displaying purpose
public static string GetFileSizeKb(double fileSize)

Parameters

fileSize double
The filesize in bytes.

Returns

string

GetFullFilePath(string)

Returns the full phisical path to the current file.
public static string GetFullFilePath(string file)

Parameters

file string
Current file.

Returns

string

GetImagesFolderName()

Gets the name of the image folder. I.e "Billeder" in /Files/Billeder/
[Obsolete("Use 'Images' instead.")]
public static string GetImagesFolderName()

Returns

string

Remarks

Specified in GlobalSettings.aspx/config - /Globalsettings/System/Filesystem/ImagesFolderName. Default value is "Billeder"

GetValidFileAndFolderName(string)

Gets the name of the valid file and folder.
public static string GetValidFileAndFolderName(string folderName)

Parameters

folderName string
Name of the folder.

Returns

string

IsValidFileAndFolderName(string)

Determines whether [is valid file and folder name] [the specified folder name].
public static bool IsValidFileAndFolderName(string folderName)

Parameters

folderName string
Name of the folder.

Returns

bool
true if [is valid file and folder name] [the specified folder name]; otherwise, false.

MakeFolder(string, string)

Creates a new folder.
public static OperationReport MakeFolder(string destination, string folderName)

Parameters

destination string
Current folder.
folderName string
New folder.

Returns

OperationReport

MoveFile(string, string)

Moves the current file to the destination file.
public static OperationReport MoveFile(string file, string destinationFolder)

Parameters

file string
File to move.
destinationFolder string
Where to move.

Returns

OperationReport
Report.

MoveFiles(string[], string)

Moves the current file to the destination file.
public static OperationReport MoveFiles(string[] files, string destinationFolder)

Parameters

files string[]
destinationFolder string

Returns

OperationReport
Report.

Remarks

Overloads.The overwrite parameter is False.

MoveFiles(string[], string, bool)

Moves the current file to the destination file.
public static OperationReport MoveFiles(string[] files, string destinationFolder, bool overwrite)

Parameters

files string[]
File to move.
destinationFolder string
Where to move.
overwrite bool
Whether destination file can be overwrited.

Returns

OperationReport
Report.

Remarks

If operation is succeeded then calls the logger.

MoveFolder(string, string)

Moves current folder and all its subfolders and subfiles to another location.
public static OperationReport MoveFolder(string folder, string destination)

Parameters

folder string
Current folder.
destination string
Another location.

Returns

OperationReport
Report.

Remarks

If operation is succeeded then calls the logger.

MoveFolders(string, string)

Moves current folder and all its subfolders and subfiles to another location with permissions.
public static OperationReport MoveFolders(string folder, string destination)

Parameters

folder string
destination string

Returns

OperationReport

NormalizeFileName(string)

Normalize fille name.
public static string NormalizeFileName(string fileName)

Parameters

fileName string
The original name of the file.

Returns

string

Remarks

Reads the first bytes of a file to determined the file encoding.

ReadTextFile(string)

Reads the current text file.
public static string ReadTextFile(string file)

Parameters

file string
Current text file.

Returns

string
The string with file's text. Or "File does not exist".

RenameFile(string, string)

Renames the current file.
public static OperationReport RenameFile(string file, string newName)

Parameters

file string
Current file.
newName string
New name of the current file.

Returns

OperationReport
Report.

RenameFolder(string, string)

Renames the current folder.
public static OperationReport RenameFolder(string folder, string newName)

Parameters

folder string
Current folder.
newName string
New name.

Returns

OperationReport
Report.

Remarks

If operation is succeeded then calls the logger.

RestoreFile(string)

Restore file.
public static OperationReport RestoreFile(string file)

Parameters

file string

Returns

OperationReport
Report.

Remarks

If operation is succeeded then calls the logger.

RestoreFiles(string[])

Restore all files of the current array.
public static OperationReport RestoreFiles(string[] files)

Parameters

files string[]
The current array of files.

Returns

OperationReport
Report.

Remarks

If operation is succeeded then calls the logger.

TrimLongFileName(string, string, string)

public static string TrimLongFileName(string longFileName, string extension, string folderPath)

Parameters

longFileName string
extension string
folderPath string

Returns

string

TrueDeleteFiles(string[])

Deletes all files of the current array.
public static OperationReport TrueDeleteFiles(string[] files)

Parameters

files string[]
Current array of files.

Returns

OperationReport
Report.

TryMakeWritable(string)

Tries to make the given file writable.
public static bool TryMakeWritable(string path)

Parameters

path string
Physical path to the file.

Returns

bool
Value indicating whether file has been successfully made writable.

ValidateFilename(string)

Checks if the fileNameWithPath contains any characters that are illegal in a filename
public static bool ValidateFilename(string fileNameWithPath)

Parameters

fileNameWithPath string
The file name with it's path.

Returns

bool
True if fileNameWithPath contains no illegal characters and is valid, otherwise False

WriteTextFile(string, string)

Writes text to the current file.
public static OperationReport WriteTextFile(string file, string text)

Parameters

file string
Current file.
text string
Current text.

Returns

OperationReport
Report.
To top