Class FileTools
Some utils for working with files (mainly filename)
Inheritance
Namespace:Dapplo.Addons.Bootstrapper.Resolving
Assembly:Dapplo.Addons.Bootstrapper.dll
Syntax
public static class FileTools : object
Methods
| Improve this Doc View SourceFilenameToRegex(String, IEnumerable<String>, Boolean, String)
Create a regex to find the specified file with wildcards.
Declaration
public static Regex FilenameToRegex(string filename, IEnumerable<string> extensions, bool ignoreCase = true, string prefix = "^(.*\\\\)*")
Parameters
Type | Name | Description |
---|---|---|
System.String | filename | string with the filename pattern to match, like Dapplo.* is allowed. Together with extensions "dll" and "dll.gz" this would be converted to Dapplo..*(.dll|.dll.gz)$ (the . in the filename pattern is NOT a any, for this a ? should be used) |
IEnumerable<System.String> | extensions | Extensions which need to be matched allowed |
System.Boolean | ignoreCase | default is true and makes sure the case is ignored |
System.String | prefix | The prefix by default restricts the match to be a complete filename, independend of the path before it. For resources the predix could be the namespace but you can also specify the directory up to the file if you want a concrete fix. |
Returns
Type | Description |
---|---|
Regex | Regex representing the filename pattern |
RemoveExtensions(String, IEnumerable<String>)
Remove extensions from a filename / path
Declaration
public static string RemoveExtensions(string filepath, IEnumerable<string> extensions = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | string with a filename or path |
IEnumerable<System.String> | extensions | IEnumerable with extensions to remove |
Returns
Type | Description |
---|---|
System.String | string |