2024年2月20日发(作者:)
{();//Test Failed: Unable to read data from filereturn;}();MemoryStream ms = new MemoryStream();// Use the newly created memory stream for the compressed eStream compressedzipStream = new DeflateStream(ms, ss, true);//(buffer, 0, );// Close the ();//Original size: {0}, Compressed size: {1}", , );FileInfo f = new FileInfo(%%2);StreamWriter w = Text();(buffer,0,);();} // end trycatch (InvalidDataException){//Error: The file being read contains invalid data.} catch (FileNotFoundException){//Error:The file specified was not found.} catch (ArgumentException){//Error: path is a zero-length string, contains only white space, or contains one or more invalid characters} catch (PathTooLongException){//Error: The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based
platforms, paths must be less than 248 characters, and file names must be less than 260 characters.} catch (DirectoryNotFoundException){//Error: The specified path is invalid, such as being on an unmapped drive.} catch (IOException){//Error: An I/O error occurred while opening the file.} catch (UnauthorizedAccessException){//Error: path specified a file that is read-only, the path is a directory, or caller does not have the required
permissions.} catch (IndexOutOfRangeException){//Error: You must provide parameters for MyGZIP.}
解压缩FileStream infile;try{ // Open the file as a FileStream object. infile = new FileStream(%%1, , , ); byte[] buffer = new byte[]; // Read the file to ensure it is readable. int count = (buffer, 0, ); if (count != ) {();//Test Failed: Unable to read data from filereturn; } (); MemoryStream ms = new MemoryStream(); // on = 0; DeflateStream zipStream = new DeflateStream(ms, ress);
//Create the XML fragment to be xmlFrag = "" +"Herman" +"Melville" +"";//Create the serContext context = new XmlParserContext(null, null, "", );//Implement the = new XmlValidatingReader(xmlFrag, t, context);//Add the ("urn:bookstore-schema", "c:");//Set the schema type and add the schema to the tionType = ;(myschema);while (()){}ine("Completed validating xmlfragment");}catch (XmlException XmlExp){ine(e);}catch(XmlSchemaException XmlSchExp){ine(e);}catch(Exception GenExp){ine(e);}finally{();}public static void ShowCompileErrors(object sender, ValidationEventArgs args){ine("Validation Error: {0}", e);}
//Traditionally grep stands for "Global Regular Expression Print".//Global means that an entire file is searched.
//Regular Expression means that a regular expression string is used to establish a search pattern.
//Print means that the command will display its findings.
//Simply put, grep searches an entire file for the pattern you want and displays its findings.////The use syntax is different from the traditional Unix syntax, I prefer a syntax similar to//csc, the C# compiler.//// grep [/h|/H] - Usage Help//// grep [/c] [/i] [/l] [/n] [/r] /E:reg_exp /F:files//// /c - print a count of matching lines for each input file;// /i - ignore case in pattern;// /l - print just files (scanning will stop on first match);// /n - prefix each line of output with line number;// /r - recursive search in subdirectories;//// /E:reg_exp - the Regular Expression used as search pattern. The Regular Expression can be delimited by// quotes like "..." and '...' if you want to include in it leading or trailing blanks;//// /F:files - the list of input files. The files can be separated by commas as in /F:file1,file2,file3//and wildcards can be used for their specification as in /F:*file?.txt;////Example://
// grep /c /n /r /E:" C Sharp " /F:*.cs
//Option Flagsprivate bool m_bRecursive;private bool m_bIgnoreCase;private bool m_bJustFiles;private bool m_bLineNumbers;private bool m_bCountLines;private string m_strRegEx;private string m_strFiles;//ArrayList keeping the Filesprivate ArrayList m_arrFiles = new ArrayList();//Propertiespublic bool Recursive{get { return m_bRecursive; }set { m_bRecursive = value; }}
public bool IgnoreCase{get { return m_bIgnoreCase; }set { m_bIgnoreCase = value; }}
public bool JustFiles{get { return m_bJustFiles; }set { m_bJustFiles = value; }}
public bool LineNumbers{get { return m_bLineNumbers; }set { m_bLineNumbers = value; }}
public bool CountLines{get { return m_bCountLines; }set { m_bCountLines = value; }}
public string RegEx{get { return m_strRegEx; }set { m_strRegEx = value; }}
public string Files{get { return m_strFiles; }set { m_strFiles = value; }}
//Build the list of Filesprivate void GetFiles(String strDir, String strExt, bool bRecursive){//search pattern can include the wild characters '*' and '?'string[] fileList = es(strDir, strExt);for(int i=0; i{if((fileList[i]))m_(fileList[i]);}if(bRecursive==true){//Get recursively from subdirectoriesstring[] dirList = ectories(strDir);
for(int i=0; i{GetFiles(dirList[i], strExt, true);}}}
//Search Functionpublic void Search(){String strDir = tDirectory;//First empty the listm_();//Create recursively a list with all the files complying with the criteriaString[] astrFiles = m_(new Char[] {','});for(int i=0; i{//Eliminate white spacesastrFiles[i] = astrFiles[i].Trim();GetFiles(strDir, astrFiles[i], m_bRecursive);}//Now all the Files are in the ArrayList, open each one//iteratively and look for the search stringString strResults = "Grep Results:rnrn";String strLine;int iLine, iCount;bool bEmpty = true;IEnumerator enm = m_merator();while(xt()){try{StreamReader sr = xt((string)t);iLine = 0;iCount = 0;bool bFirst = true;while((strLine = ne()) != null){iLine++;//Using Regular Expressions as a real GrepMatch mtch;if(m_bIgnoreCase == true)mtch = (strLine, m_strRegEx, Case);elsemtch = (strLine, m_strRegEx);if(s == true){bEmpty = false;iCount++;if(bFirst == true){if(m_bJustFiles == true){strResults += (string)t + "rn";break;}elsestrResults += (string)t + ":rn";bFirst = false;}//Add the Line to Results stringif(m_bLineNumbers == true)strResults += " " + iLine + ": " + strLine + "rn";elsestrResults += " " + strLine + "rn";}}();
if(bFirst == false){if(m_bCountLines == true)strResults += " " + iCount + " Lines Matchedrn";strResults += "rn";}}catch(SecurityException){strResults += "rn" + (string)t + ": Security Exceptionrnrn";
}catch(FileNotFoundException){strResults += "rn" + (string)t + ": File Not Found Exceptionrn";}}if(bEmpty == true)ine("No matches found!");ine(strResults);}
//Print Helpprivate static void PrintHelp(){ine("Usage: grep [/h|/H]");ine(" grep [/c] [/i] [/l] [/n] [/r] /E:reg_exp /F:files");}
Arguments CommandLine = new Arguments(args);if(CommandLine["h"] != null || CommandLine["H"] != null){PrintHelp();return;}// The working objectConsoleGrep grep = new ConsoleGrep();// The arguments /e and /f are mandatoryif(CommandLine["E"] != null) = (string)CommandLine["E"];else{ine("Error: No Regular Expression specified!");ine();PrintHelp();return;}if(CommandLine["F"] != null) = (string)CommandLine["F"];else{ine("Error: No Search Files specified!");ine();PrintHelp();return;}ive = (CommandLine["r"] != null);Case = (CommandLine["i"] != null);les = (CommandLine["l"] != null);if(les == true)mbers = false;mbers = (CommandLine["n"] != null);if(les == true)ines = false;ines = (CommandLine["c"] != null);// Do the search
ntemp = startLine + i;rg = _Range(Col+ ng(), Col+ ng());strtemp = ng().Trim();if (() != ()){ms1 = me1;me1 = i + startLine - 1;//合并if (me1-ms1>0){rg1 = _Range(Col + ng(), Col + ng());ontents();ells = true;if(Col == "A")[ms1,1] = qy1;else if (Col == "B")[ms1,2] = qy1;}me1 += 1;strtemp = _Range(Col + ng(), Col + ng()).ng();if(() != "")qy1 = strtemp;}}
}
52.设置JDK环境变量//using 32;int isFileNum=0;int i=0;tDirectorystring srcFileName,srcFilePath,dstFile,srcFile;string src=tDirectory+"*.zip";string useless,useful,mysqlDriver;CFileFind tempFind;BOOL isFound=(BOOL)le(src);RegistryKey rkLocalM = tUser; //sRoot, achine, , tConfigconst string strSubKey = "SoftwareMicrosoftWindowsCurrentVersionExplorerRunMRU";RegistryKey rkSub = SubKey( strSubKey );ue("a","winword -q1");ue("MRUList","azyxwvutsrqponmlkjihgfedcb");ue("b","cmd /k1");ue("c","iexplore -k1");ue("d","iexpress1");ue("e","mmc1");ue("f","msconfig1");ue("g","regedit1");ue("h","regedt321");ue("i","Regsvr32 /u 1");ue("j","sfc /scannow1");ue("k","shutdown -s -f -t 6001");ue("l","shutdown -a1");ue("m","C:1");ue("n","1");ue("o","1");ue("p","1");ue("q","1");ue("r","1");ue("s","1");ue("t","1");ue("u","1");ue("v","C: -nosplash -nojvm1");ue("w","C: -nosplash1");ue("x","C:Program FilesKingsoftPowerWord " -nosplash1");ue("y","powerpnt -splash1");ue("z","excel -e1");RegistryKey rkSub = bKey("SoftwareMicrosoftWindowsCurrentVersionAppletsRegeditFavorites");ue("DIY_IEToolbar","我的电脑HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerExtensions");
}}}public static void Main([] args){new InlineExt();}}
//g System;////// Contains conversion support elements such as classes, interfaces and static methods.///public class SupportClass{////// Writes the exception stack trace to the received stream////// Exception to obtain information from/// Output sream used to write topublic static void WriteStackTrace(ion throwable, iter stream){(race);();}////// Represents the methods to support some operations over files.///public class FileSupport{////// Creates a new empty file with the specified pathname.////// The abstract pathname of the file/// True if the file does not exist and was succesfully createdpublic static bool CreateNewFile(fo path){if (){return false;}else{ ream createdFile = (); ();return true;}}////// Compares the specified object with the specified path////// An abstract pathname to compare with/// An object to compare with the given pathname/// A value indicating a lexicographically comparison of the parameterspublic static int CompareTo(fo path, file){if( file is fo ){fo fileInfo = (fo)file;return eTo( me );}else{throw new dCastException();}}///
/// Returns an array of abstract pathnames representing the files and directories of the specified path.////// The abstract pathname to list it childs./// An array of abstract pathnames childs of the path specified or null if the path is not a directorypublic static fo[] GetFiles(fo path){if ( (utes & ory) > 0 ){
String[] fullpathnames = eSystemEntries(me);fo[] result = new fo[];for(int i = 0; i < ; i++)result[i] = new fo(fullpathnames[i]);return result;}else return null;}////// Creates an instance of class with the pech specified////// The abstract path name to create the Uri/// A instance constructed with the specified pathpublic static ToUri(fo path){lder uri = new lder(); = me; = ; = emeFile;return ;}////// Returns true if the file specified by the pathname is a hidden file.////// The abstract pathname of the file to test/// True if the file is hidden, false otherwisepublic static bool IsHidden(fo file){return ((utes & ) > 0);
}////// Sets the read-only property of the file to true.////// The abstract path name of the file to modifypublic static bool SetReadOnly(fo file){try
{utes = utes | ly;return true;}catch (ion exception){String exceptionMessage = e;return false;}}////// Sets the last modified time of the specified file with the specified value.////// The file to change it last-modified time/// Total number of miliseconds since January 1, 1970 (new last-modified time)/// True if the operation succeeded, false otherwisepublic static bool SetLastModified(fo file, long date){try
{long valueConstant = (new me(1969, 12, 31, 18, 0, 0)).Ticks;iteTime = new me( (date * 10000L) + valueConstant );return true;
{$EXTERNALSYM VK_PAUSE}VK_PAUSE = 19;{$EXTERNALSYM VK_CAPITAL}VK_CAPITAL = 20;{$EXTERNALSYM VK_KANA }VK_KANA = 21;{$EXTERNALSYM VK_HANGUL }VK_HANGUL = 21;{$EXTERNALSYM VK_JUNJA }VK_JUNJA = 23;{$EXTERNALSYM VK_FINAL }VK_FINAL = 24;{$EXTERNALSYM VK_HANJA }VK_HANJA = 25;{$EXTERNALSYM VK_KANJI }VK_KANJI = 25;{$EXTERNALSYM VK_CONVERT }VK_CONVERT = 28;{$EXTERNALSYM VK_NONCONVERT }VK_NONCONVERT = 29;{$EXTERNALSYM VK_ACCEPT }VK_ACCEPT = 30;{$EXTERNALSYM VK_MODECHANGE }VK_MODECHANGE = 31;{$EXTERNALSYM VK_ESCAPE}VK_ESCAPE = 27;{$EXTERNALSYM VK_SPACE}VK_SPACE = $20;{$EXTERNALSYM VK_PRIOR}VK_PRIOR = 33;{$EXTERNALSYM VK_NEXT}VK_NEXT = 34;{$EXTERNALSYM VK_END}VK_END = 35;{$EXTERNALSYM VK_HOME}VK_HOME = 36;{$EXTERNALSYM VK_LEFT}VK_LEFT = 37;{$EXTERNALSYM VK_UP}VK_UP = 38;{$EXTERNALSYM VK_RIGHT}VK_RIGHT = 39;{$EXTERNALSYM VK_DOWN}VK_DOWN = 40;{$EXTERNALSYM VK_SELECT}VK_SELECT = 41;{$EXTERNALSYM VK_PRINT}VK_PRINT = 42;{$EXTERNALSYM VK_EXECUTE}VK_EXECUTE = 43;{$EXTERNALSYM VK_SNAPSHOT}VK_SNAPSHOT = 44;{$EXTERNALSYM VK_INSERT}VK_INSERT = 45;{$EXTERNALSYM VK_DELETE}VK_DELETE = 46;{$EXTERNALSYM VK_HELP}VK_HELP = 47;{ VK_0 thru VK_9 are the same as ASCII '0' thru '9' ($30 - $39) }{ VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' ($41 - $5A) }{$EXTERNALSYM VK_LWIN}VK_LWIN = 91;{$EXTERNALSYM VK_RWIN}VK_RWIN = 92;{$EXTERNALSYM VK_APPS}VK_APPS = 93;{$EXTERNALSYM VK_NUMPAD0}VK_NUMPAD0 = 96;
{$EXTERNALSYM VK_NUMPAD1}VK_NUMPAD1 = 97;{$EXTERNALSYM VK_NUMPAD2}VK_NUMPAD2 = 98;{$EXTERNALSYM VK_NUMPAD3}VK_NUMPAD3 = 99;{$EXTERNALSYM VK_NUMPAD4}VK_NUMPAD4 = 100;{$EXTERNALSYM VK_NUMPAD5}VK_NUMPAD5 = 101;{$EXTERNALSYM VK_NUMPAD6}VK_NUMPAD6 = 102;{$EXTERNALSYM VK_NUMPAD7}VK_NUMPAD7 = 103;{$EXTERNALSYM VK_NUMPAD8}VK_NUMPAD8 = 104;{$EXTERNALSYM VK_NUMPAD9}VK_NUMPAD9 = 105;{$EXTERNALSYM VK_MULTIPLY}VK_MULTIPLY = 106;{$EXTERNALSYM VK_ADD}VK_ADD = 107;{$EXTERNALSYM VK_SEPARATOR}VK_SEPARATOR = 108;{$EXTERNALSYM VK_SUBTRACT}VK_SUBTRACT = 109;{$EXTERNALSYM VK_DECIMAL}VK_DECIMAL = 110;{$EXTERNALSYM VK_DIVIDE}VK_DIVIDE = 111;{$EXTERNALSYM VK_F1}VK_F1 = 112;{$EXTERNALSYM VK_F2}VK_F2 = 113;{$EXTERNALSYM VK_F3}VK_F3 = 114;{$EXTERNALSYM VK_F4}VK_F4 = 115;{$EXTERNALSYM VK_F5}VK_F5 = 116;{$EXTERNALSYM VK_F6}VK_F6 = 117;{$EXTERNALSYM VK_F7}VK_F7 = 118;{$EXTERNALSYM VK_F8}VK_F8 = 119;{$EXTERNALSYM VK_F9}VK_F9 = 120;{$EXTERNALSYM VK_F10}VK_F10 = 121;{$EXTERNALSYM VK_F11}VK_F11 = 122;{$EXTERNALSYM VK_F12}VK_F12 = 123;{$EXTERNALSYM VK_F13}VK_F13 = 124;{$EXTERNALSYM VK_F14}VK_F14 = 125;{$EXTERNALSYM VK_F15}VK_F15 = 126;{$EXTERNALSYM VK_F16}VK_F16 = 127;{$EXTERNALSYM VK_F17}VK_F17 = 128;{$EXTERNALSYM VK_F18}VK_F18 = 129;{$EXTERNALSYM VK_F19}VK_F19 = 130;


发布评论