Esempio n. 1
0
        /// <summary>Returns the timestamp when the file was created</summary>
        /// <param name="FilePath"> </param>
        public static DateTime CreationTime(this string FilePath)
        {
            _AHK ahk = new _AHK();

            return(ahk.CreationTime(FilePath));
        }
Esempio n. 2
0
        /// <summary>Converts a string to uppercase.</summary>
        /// <param name="InputVar">The name of the variable whose contents will be read from. Do not enclose the name in percent signs unless you want the contents of the variable to be used as the name.</param>
        /// <param name="ProperCase">If this parameter is True, the string will be converted to title case. For example, "GONE with the WIND" would become "Gone With The Wind". </param>
        public static string StringUpper(this string InputVar, bool ProperCase = false)
        {
            _AHK ahk = new _AHK();

            return(ahk.StringUpper(InputVar, ProperCase));
        }
Esempio n. 3
0
        /// <summary>Replaces the specified substring with a new string.</summary>
        /// <param name="InputVar">The name of the variable whose contents will be read from. Do not enclose the name in percent signs unless you want the contents of the variable to be used as the name.</param>
        /// <param name="SearchText">The string to search for. Matching is not case sensitive unless StringCaseSense has been turned on.</param>
        /// <param name="ReplaceText">SearchText will be replaced with this text. If omitted or blank, SearchText will be replaced with blank (empty). In other words, it will be omitted from OutputVar.</param>
        /// <param name="ReplaceAll">If omitted, only the first occurrence of SearchText will be replaced. But if this parameter is 1, A, or All, all occurrences will be replaced. Specify the word UseErrorLevel to store in ErrorLevel the number of occurrences replaced (0 if none). UseErrorLevel implies "All".</param>
        public static string StringReplace(this string InputVar, string SearchText, string ReplaceText = "", string ReplaceAll = "", int Mode = 1)
        {
            _AHK ahk = new _AHK();

            return(ahk.StringReplace(InputVar, SearchText, ReplaceText, ReplaceAll, Mode));
        }
Esempio n. 4
0
        /// <summary>Backup File to Backup Dir with .# ext (also puts \Backup\OriginalName.ext as most recent file copy for opening)</summary>
        /// <param name="FilePath">Path of Original File To Backup</param>
        /// <param name="DeleteOriginal">Option to Delete Original File After Successful Backup</param>
        /// <param name="BackupDir">Directory To Store Backup File. Default = AppDir\\Backup</param>
        /// <returns>Returns True on Successful Backup</returns>
        public static bool Backup_File(string FilePath, bool DeleteOriginal = false, string BackupDir = "\\Backup")
        {
            _AHK ahk = new _AHK();

            return(ahk.Backup_File(FilePath, DeleteOriginal, BackupDir));
        }
Esempio n. 5
0
        /// <summary>Backup File + Display New Backup File Location on GUI</summary>
        /// <param name="FilePath">Path of Original File To Backup</param>
        /// <param name="DisplayControl">WinForm Control Name To Display Backup File Path Returned</param>
        /// <param name="UseSameNameMostRecent">Overrides Using .# Backup Uses Most Recent Copy of File. Default = True</param>
        public static bool Backup_File_Display(string FilePath, Control DisplayControl, bool UseSameNameMostRecent = true)
        {
            _AHK ahk = new _AHK();

            return(ahk.Backup_File_Display(FilePath, DisplayControl, UseSameNameMostRecent));
        }
Esempio n. 6
0
        /// <summary>
        /// Returns List of Folders in Directory Path
        /// </summary>
        /// <param name="DirPath"> </param>
        /// <param name="SearchPattern"> </param>
        /// <param name="Recurse"> </param>
        /// <param name="FullPathReturn">Option to return either the Full Directory Paths (true) or the Directory name list (false)</param>
        public static List <string> DirList(this string DirPath, string SearchPattern = "*.*", bool Recurse = true, bool FullPathReturn = false)
        {
            _AHK ahk = new _AHK();

            return(ahk.DirList(DirPath, SearchPattern, Recurse, FullPathReturn));
        }
Esempio n. 7
0
        /// <summary>Deletes one or more files.</summary>
        /// <param name="FilePattern">The name of a single file or a wildcard pattern such as C:\Temp\*.tmp. FilePattern is assumed to be in %A_WorkingDir% if an absolute path isn't specified.</param>
        /// <param name="PromptUser">Option to Prompt User with Yes/No PopUp Dialog Before Deleting (Default = False)</param>
        public static bool FileDelete(this string FilePattern, bool PromptUser = false)
        {
            _AHK ahk = new _AHK();

            return(ahk.FileDelete(FilePattern, PromptUser));
        }
Esempio n. 8
0
        /// <summary>Deletes a folder.</summary>
        /// <param name="DirName">Name of the directory to delete, which is assumed to be in %A_WorkingDir% if an absolute path isn't specified.</param>
        /// <param name="Recurse">Recurse = False - Do not remove files and sub-directories contained in DirName. In this case, if DirName is not empty, no action will be taken | True = Remove all files and subdirectories.</param>
        public static bool FileRemoveDir(this string DirName, bool Recurse = false)
        {
            _AHK ahk = new _AHK();

            return(ahk.FileRemoveDir(DirName, Recurse));
        }
Esempio n. 9
0
        /// <summary>
        /// Adds shortcut to application for current executable in user's startup directory
        /// </summary>
        public static void AppShortcutToStartup()
        {
            _AHK ahk = new _AHK();

            ahk.AppShortcutToStartup();
        }
Esempio n. 10
0
        /// <summary>Creates a directory/folder. (Same As FileCreateDir)</summary>
        /// <param name="DirName">Name of the directory to create, which is assumed to be in %A_WorkingDir% if an absolute path isn't specified.</param>
        public static bool CreateDir(this string DirName)
        {
            _AHK ahk = new _AHK();

            return(ahk.FileCreateDir(DirName));
        }
Esempio n. 11
0
        /// <summary>Moves a folder along with all its sub-folders and files. It can also rename a folder. (Same as FileMoveDir)</summary>
        /// <param name="Source">Name of the source directory (with no trailing backslash), which is assumed to be in %A_WorkingDir% if an absolute path isn't specified.</param>
        /// <param name="Dest">The new path and name of the directory (with no trailing baskslash), which is assumed to be in %A_WorkingDir% if an absolute path isn't specified. For example: D:\My Folder. Note: Dest is the actual path and name that the directory will have after it is moved; it is not the directory into which Source is moved (except for the known limitation mentioned below).</param>
        /// <param name="Flag">0 (default): Do not overwrite existing files. | 1: Overwrite existing files. However, any files or subfolders inside Dest that do not have a counterpart in Source will not be deleted. | 2: The same as mode 1 above except that the limitation is absent. | R: Rename the directory rather than moving it. </param>
        public static bool MoveDir(this string Source, string Dest, string Flag = "0")
        {
            _AHK ahk = new _AHK();

            return(ahk.FileMoveDir(Source, Dest, Flag));
        }
Esempio n. 12
0
        /// <summary>Copies a folder along with all its sub-folders and files (similar to xcopy) (Same as FileCopyDir)</summary>
        /// <param name="Source">Name of the source directory (with no trailing backslash), which is assumed to be in %A_WorkingDir% if an absolute path isn't specified.</param>
        /// <param name="Dest">Name of the destination directory (with no trailing baskslash), which is assumed to be in %A_WorkingDir% if an absolute path isn't specified.</param>
        /// <param name="OverWrite">Flag determines whether to overwrite files if they already exist. True = OverWrite Existing Files</param>
        public static bool CopyDir(this string Source, string Dest, bool OverWrite = false)
        {
            _AHK ahk = new _AHK();

            return(ahk.FileCopyDir(Source, Dest, OverWrite));
        }
Esempio n. 13
0
        /// <summary>Returns the timestamp when the file was last accessed</summary>
        /// <param name="FilePath"> </param>
        public static DateTime LastAccessTime(this string FilePath)
        {
            _AHK ahk = new _AHK();

            return(ahk.LastAccessTime(FilePath));
        }
Esempio n. 14
0
        /// <summary>Creates a shortcut (.lnk) file.</summary>
        /// <param name="Target">Name of the file that the shortcut refers to, which should include an absolute path unless the file is integrated with the system (e.g. Notepad.exe).</param>
        /// <param name="LinkFile">Name of the shortcut file to be created, which is assumed to be in %A_WorkingDir% if an absolute path isn't specified. Be sure to include the .lnk extension. If the file already exists, it will be overwritten.</param>
        /// <param name="WorkingDir">Directory that will become Target's current working directory when the shortcut is launched. If blank or omitted, the shortcut will have a blank "Start in" field and the system will provide a default working directory when the shortcut is launched.</param>
        /// <param name="Args">Parameters that will be passed to Target when it is launched. Separate parameters with spaces. If a parameter contains spaces, enclose it in double quotes.</param>
        /// <param name="Description">Comments that describe the shortcut (used by the OS to display a tooltip, etc.)</param>
        /// <param name="IconFile">The full path and name of the icon to be displayed for LinkFile. It must either be an ico file or the very first icon of an EXE or DLL.</param>
        /// <param name="ShortcutKey">A single letter, number, or the name of a single key from the key list (mouse buttons and other non-standard keys might not be supported). Do not include modifier symbols. Currently, all shortcut keys are created as CTRL+ALT shortcuts. For example, if the letter B is specified for this parameter, the shortcut key will be CTRL-ALT-B.</param>
        /// <param name="IconNumber">To use an icon in IconFile other than the first, specify that number here (can be an expression). For example, 2 is the second icon.</param>
        /// <param name="RunState">To have Target launched minimized or maximized, specify one of the following digits: 1 - Normal (this is the default) | 3 - Maximized | 7 - Minimized</param>
        public static bool FileCreateShortcut(this string Target, string LinkFile, string WorkingDir = "", string Args = "", string Description = "", string IconFile = "", string ShortcutKey = "", string IconNumber = "", string RunState = "")
        {
            _AHK ahk = new _AHK();

            return(ahk.FileCreateShortcut(Target, LinkFile, WorkingDir, Args, Description, IconFile, ShortcutKey, IconNumber, RunState));
        }
Esempio n. 15
0
        /// <summary>Returns the next available file name in a folder, incrementing with "File (FileNumber).ext" Format</summary>
        /// <param name="FilePath">Original File Name</param>
        public static string NextFileName(this string FilePath, int LeadingZeroCount = 0)
        {
            _AHK ahk = new _AHK();

            return(ahk.NextFileName(FilePath, LeadingZeroCount));
        }
Esempio n. 16
0
        /// Retired (Redundant)
        ///// <summary>Opens Directory in Windows Explorer containing FilePath</summary>
        ///// <param name="FilePath">Path to file, extracting the folder path to open</param>
        //public static bool OpenFileDir(this string FilePath)
        //{
        //    _AHK ahk = new _AHK();
        //    return ahk.OpenFileDir(FilePath);
        //}

        // File Compare

        #region === File Compare / Hash ===

        /// <summary>
        /// Returns Hash value for File
        /// </summary>
        /// <param name="FilePath"></param>
        /// <returns></returns>
        public static string FileHash(this string FilePath)
        {
            _AHK ahk = new _AHK();

            return(ahk.FileHash(FilePath));
        }
Esempio n. 17
0
        // File Lists

        /// <summary>
        /// Returns List<string> of files in directory path
        /// </summary>
        /// <param name="DirPath"> </param>
        /// <param name="SearchPattern"> </param>
        /// <param name="Recurse"> </param>
        /// <param name="FileNameOnly"> </param>
        /// <param name="IncludeExt"> </param>
        public static List <string> FileList(this string DirPath, string SearchPattern = "*.*", bool Recurse = true, bool FileNameOnly = false, bool IncludeExt = true)
        {
            _AHK ahk = new _AHK();

            return(ahk.FileList(DirPath, SearchPattern, Recurse, FileNameOnly, IncludeExt));
        }
Esempio n. 18
0
        /// <summary>
        /// Compare 2 Files To See if they are the same (either compares Hash or Bytes)
        /// </summary>
        /// <param name="fileOne">First File To Compare</param>
        /// <param name="fileTwo">Second File to Compare</param>
        /// <param name="Hash">Option to Compare File Hashes (Default = True). If False, Compares by Bytes</param>
        /// <returns>Returns True if Files are the Same</returns>
        public static bool FileCompare(this string fileOne, string fileTwo, bool Hash = true)
        {
            _AHK ahk = new _AHK();

            return(ahk.FileCompare(fileOne, fileTwo, Hash));
        }
Esempio n. 19
0
        /// <summary>
        /// Format String Removing Illegal Characters - Allowed to Save As File In Windows
        /// </summary>
        /// <param name="FileName"></param>
        /// <param name="ReplaceChar">Character to replace illegal characters with, Default = Space</param>
        /// <returns></returns>
        public static string SafeSaveName(this string FileName, string ReplaceChar = " ")
        {
            _AHK ahk = new _AHK();

            return(ahk.SafeSaveName(FileName, ReplaceChar));
        }
Esempio n. 20
0
        /// <summary>
        /// Compares two image paths using hash - returns true if match found
        /// </summary>
        /// <param name="file1"></param>
        /// <param name="file2"></param>
        /// <returns></returns>
        public static bool FileCompare_Hash(this string file1, string file2)
        {
            _AHK ahk = new _AHK();

            return(ahk.FileCompare_Hash(file1, file2));
        }
Esempio n. 21
0
        // === File Backup ===

        //private static bool GlobalDebug = false;

        /// <summary>Restores Last Backup File Copy in BackupDir to Original Location</summary>
        /// <param name="FilePath">Path of Original File Previously Backed Up</param>
        /// <param name="Prompt">Option to Prompt User Before Restoring Backup</param>
        /// <param name="BackupDir">Directory To Store Backup File. Default = AppDir\\Backup</param>
        public static bool Restore_Backup(string FilePath, bool Prompt = false, string BackupDir = "\\Backup")
        {
            _AHK ahk = new _AHK();

            return(ahk.Restore_Backup(FilePath, Prompt, BackupDir));
        }
Esempio n. 22
0
        //====== Dir Print ==============================================

        // string DirectoryFilePaths = ahk.DirPrint("C:\\CCSM", true, "c:\\OutFile.txt", "*.txt", true);

        /// <summary>
        /// Prints List of Files in Directory to String or New Text File
        /// </summary>
        /// <param name="SearchDir">Directory to Loop through for File Paths</param>
        /// <param name="OutFile">If path provided, writes contents of directory to this to new/existing text file</param>
        /// <param name="Recurse">Option to Search Files in Subdirectories (aka Recurse) Default = True</param>
        /// <param name="SearchPattern">File pattern to search for</param>
        /// <param name="OverWritePrevious">Option to overwrite previous OutFile if it exists (Default = True)</param>
        /// <param name="OpenAfterWrite">If OutFile path provided, option to open new text file after writing (Default = True)</param>
        /// <returns>Returns string with list of file paths under SearchDir</returns>
        public static string DirPrint(this string SearchDir, string OutFile = "", bool Recurse = true, string SearchPattern = "*.*", bool OverWritePrevious = true, bool OpenAfterWrite = true)
        {
            _AHK ahk = new _AHK();

            return(ahk.DirPrint(SearchDir, OutFile, Recurse, SearchPattern, OverWritePrevious, OpenAfterWrite));
        }
Esempio n. 23
0
        /// <summary>Returns Path of the Last Backup File Created for this File Name</summary>
        /// <param name="FilePath">Path of Original File To Backup</param>
        /// <param name="BackupDir">Directory To Store Backup File. Default = AppDir\\Backup</param>
        /// <param name="UseSameNameMostRecent">Overrides Using .# Backup Uses Most Recent Copy of File. Default = True</param>
        public static string Last_Backup_File(string FilePath, string BackupDir = "\\Backup", bool UseSameNameMostRecent = true)
        {
            _AHK ahk = new _AHK();

            return(ahk.Last_Backup_File(FilePath, BackupDir, UseSameNameMostRecent));
        }
Esempio n. 24
0
        /// <summary>Converts search directory contents to Datatable to display in DataGridView etc</summary>
        /// <param name="SearchDir"> </param>
        /// <param name="Recurse"> </param>
        /// <param name="SearchPattern"> </param>
        public static DataTable GetDirectoryTable(this string SearchDir, bool Recurse = true, string SearchPattern = "*.*")
        {
            _AHK ahk = new _AHK();

            return(ahk.GetDirectoryTable(SearchDir, Recurse, SearchPattern));
        }
Esempio n. 25
0
        /// <summary>Reports whether a file or folder is read-only, hidden, etc.</summary>
        /// <param name="Filename">The name of the target file, which is assumed to be in %A_WorkingDir% if an absolute path isn't specified.</param>
        public static string FileGetAttrib(this string Filename)
        {
            _AHK ahk = new _AHK();

            return(ahk.FileGetAttrib(Filename));
        }
Esempio n. 26
0
        /// <summary>
        /// Creates URL shortcut on user's pc (default location = desktop)
        /// </summary>
        /// <param name="linkName">Name of URL ShortCut/Site</param>
        /// <param name="linkUrl">URL for new Link</param>
        /// <param name="SaveDir">Directory to save new link to</param>
        public static void UrlShortcutToDesktop(this string linkName, string linkUrl, string SaveDir = "Desktop")
        {
            _AHK ahk = new _AHK();

            ahk.UrlShortcutToDesktop(linkName, linkUrl, SaveDir);
        }
Esempio n. 27
0
        /// <summary>Retrieves one or more characters from the specified position in a string.</summary>
        /// <param name="InputVar">The name of the variable from whose contents the substring will be extracted. Do not enclose the name in percent signs unless you want the contents of the variable to be used as the name.</param>
        /// <param name="StartChar">The position of the first character to be extracted, which can be an expression. Unlike StringGetPos, 1 is the first character. If StartChar is less than 1, it will be assumed to be 1. If StartChar is beyond the end of the string, OutputVar is made empty (blank).</param>
        /// <param name="Count"> this parameter may be omitted or left blank, which is the same as specifying an integer large enough to retrieve all characters from the string. Otherwise, specify the number of characters to extract, which can be an expression. If Count is less than or equal to zero, OutputVar will be made empty (blank). If Count exceeds the length of InputVar measured from StartChar, OutputVar will be set equal to the entirety of InputVar starting at StartChar.</param>
        /// <param name="L">The letter L can be used to extract characters that lie to the left of StartChar rather than to the right. In the following example, OutputVar will be set to Red: InputVar = The Red Fox StringMid, OutputVar, InputVar, 7, 3, L If the L option is present and StartChar is less than 1, OutputVar will be made blank. If StartChar is beyond the length of InputVar, only those characters within reach of Count will be extracted. For example, the below will set OutputVar to Fox: InputVar = The Red Fox StringMid, OutputVar, InputVar, 14, 6, L</param>
        public static string StringMid(this string InputVar, string StartChar, string Count = "", string L = "")
        {
            _AHK ahk = new _AHK();

            return(ahk.StringMid(InputVar, StartChar, Count, L));
        }
Esempio n. 28
0
        /// <summary>Returns true if path is a valid Directory Path</summary>
        /// <param name="FolderPath"> </param>
        public static bool IsDir(this string FolderPath)  // returns true if path is a directory
        {
            _AHK ahk = new _AHK();

            return(ahk.isDir(FolderPath));
        }
Esempio n. 29
0
        /// <summary>Removes a number of characters from the right-hand side of a string.</summary>
        /// <param name="InputVar">The name of the variable whose contents will be read from. Do not enclose the name in percent signs unless you want the contents of the variable to be used as the name.</param>
        /// <param name="Count">The number of characters to remove, which can be an expression. If Count is less than or equal to zero, OutputVar will be set equal to the entirety of InputVar. If Count exceeds the length of InputVar, OutputVar will be made empty (blank).</param>
        public static string StringTrimRight(this string InputVar, string Count)
        {
            _AHK ahk = new _AHK();

            return(ahk.StringTrimRight(InputVar, Count));
        }
Esempio n. 30
0
        /// <summary>
        /// Checks FilePath's Extension to see if it matches known Image File Formats
        /// </summary>
        /// <param name="FilePath">File path to check</param>
        /// <returns>Returns True if File is Known Image File Format</returns>
        public static bool isImage(this string FilePath)
        {
            _AHK ahk = new _AHK();

            return(ahk.isImage(FilePath));
        }