日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

代码集锦

發布時間:2023/12/20 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 代码集锦 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

原帖地址:http://space.itpub.net/23109131/viewspace-662112 1.創建文件夾
//using System.IO;
Directory.CreateDirectory(%%1); 2.創建文件
//using System.IO;
File.Create(%%1); 3.刪除文件
//using System.IO;
File.Delete(%%1); 4.刪除文件夾
//using System.IO;
Directory.Delete(%%1); 5.刪除一個目錄下所有的文件夾
//using System.IO;
foreach (string dirStr in Directory.GetDirectories(%%1))
{
?DirectoryInfo dir = new DirectoryInfo(dirStr);
?ArrayList folders=new ArrayList();
?FileSystemInfo[] fileArr = dir.GetFileSystemInfos();
?for (int i = 0; i < folders.Count; i++)
?{
??FileInfo f = folders[i] as FileInfo;
??if (f == null)
??{
???DirectoryInfo d = folders[i] as DirectoryInfo;
???d.Delete();
??}
?}
} 6.清空文件夾
//using System.IO;
Directory.Delete(%%1,true);
Directory.CreateDirectory(%%1); 7.讀取文件
//using System.IO;
StreamReader s = File.OpenText(%%1);
string %%2 = null;
while ((%%2 = s.ReadLine()) != null){
?%%3
}
s.Close(); 8.寫入文件
//using System.IO;
FileInfo f = new FileInfo(%%1);
StreamWriter w = f.CreateText();
w.WriteLine(%%2);
w.Close(); 9.寫入隨機文件
//using System.IO;
byte[] dataArray = new byte[100000];//new Random().NextBytes(dataArray);
using(FileStream FileStream = new FileStream(%%1, FileMode.Create)){
// Write the?data?to the file, byte by byte.
?for(int i = 0; i < dataArray.Length; i++){
??FileStream.WriteByte(dataArray[i]);
?}
// Set the stream position to the beginning of the file.
?FileStream.Seek(0, SeekOrigin.Begin);
// Read and verify the data.
?for(int i = 0; i < FileStream.Length; i++){
??if(dataArray[i] != FileStream.ReadByte()){
???//寫入數據錯誤
???return;
??}
?}
//"數據流"+FileStream.Name+"已驗證"
} 10.讀取文件屬性
//using System.IO;
FileInfo f = new FileInfo(%%1);//f.CreationTime,f.FullName
if((f.Attributes & FileAttributes.ReadOnly) != 0){
?%%2
}
else{
?%%3
} 11.寫入屬性
//using System.IO;
FileInfo f = new FileInfo(%%1);
//設置只讀
f.Attributes = myFile.Attributes | FileAttributes.ReadOnly;
//設置可寫
f.Attributes = myFile.Attributes & ~FileAttributes.ReadOnly; 12.枚舉一個文件夾中的所有文件夾
//using System.IO;
foreach (string %%2 in Directory.GetDirectories(%%1)){
?%%3
}
/*
DirectoryInfo dir = new DirectoryInfo(%%1);
FileInfo[] files = dir.GetFiles("*.*");
foreach(FileInfo %%2 in files){
?%%3
}
*/ 13.復制文件夾
/*
using System.IO;
using System.Collections;
*/
string path = (%%2.LastIndexOf("//") == %%2.Length - 1) ? %%2 : %%2+"//";
string parent = Path.GetDirectoryName(%%1);
Directory.CreateDirectory(path + Path.GetFileName(%%1));
DirectoryInfo dir = new DirectoryInfo((%%1.LastIndexOf("//") == %%1.Length - 1) ? %%1 : %%1 + "//");
FileSystemInfo[] fileArr = dir.GetFileSystemInfos();
Queue<FileSystemInfo> Folders = new Queue<FileSystemInfo>(dir.GetFileSystemInfos());
while (Folders.Count>0)
{
??????????????????? FileSystemInfo tmp = Folders.Dequeue();
??????????????????? FileInfo f = tmp as FileInfo;
??????????????????? if (f == null)
??????????????????? {
??????????????????????? DirectoryInfo d = tmp as DirectoryInfo;
??????????????????????? Directory.CreateDirectory(d.FullName.Replace((parent.LastIndexOf("//") == parent.Length - 1) ? parent : parent + "//", path));
??????????????????????? foreach (FileSystemInfo fi in d.GetFileSystemInfos())
??????????????????????? {
??????????????????????????? Folders.Enqueue(fi);
??????????????????????? }
??????????????????? }
??????????????????? else
??????????????????? {
??????????????????????? f.CopyTo(f.FullName.Replace(parent, path));
??????????????????? }
} 14.復制目錄下所有的文件夾到另一個文件夾下
/*
using System.IO;
using System.Collections;
*/
DirectoryInfo d = new DirectoryInfo(%%1);
foreach (DirectoryInfo dirs in d.GetDirectories())
{
??? Queue<FileSystemInfo> al = new Queue<FileSystemInfo>(dirs.GetFileSystemInfos());
??? while (al.Count > 0)
??? {
??????? FileSystemInfo temp = al.Dequeue();
??????? FileInfo file = temp as FileInfo;
??????? if (file == null)
??????? {
??????????? DirectoryInfo directory = temp as DirectoryInfo;
??????????? Directory.CreateDirectory(path + directory.Name);
??????????? foreach (FileSystemInfo fsi in directory.GetFileSystemInfos())
??????????????? al.Enqueue(fsi);
??????? }
??????? else
??????????? File.Copy(file.FullName, path + file.Name);
??? }
} 15.移動文件夾
/*
using System.IO;
using System.Collections;
*/
??????????????? string filename = Path.GetFileName(%%1);
??????????????? string path=(%%2.LastIndexOf("//") == %%2.Length - 1) ? %%2 : %%2 + "//";
??????????????? if (Path.GetPathRoot(%%1) == Path.GetPathRoot(%%2))
??????????????????? Directory.Move(%%1, path + filename);
??????????????? else
??????????????? {
??????????????????? string parent = Path.GetDirectoryName(%%1);
??????????????????? Directory.CreateDirectory(path + Path.GetFileName(%%1));
??????????????????? DirectoryInfo dir = new DirectoryInfo((%%1.LastIndexOf("//") == %%1.Length - 1) ? %%1 : %%1 + "//");
??????????????????? FileSystemInfo[] fileArr = dir.GetFileSystemInfos();
??????????????????? Queue<FileSystemInfo> Folders = new Queue<FileSystemInfo>(dir.GetFileSystemInfos());
??????????????????? while (Folders.Count > 0)
??????????????????? {
??????????????????????? FileSystemInfo tmp = Folders.Dequeue();
??????????????????????? FileInfo f = tmp as FileInfo;
??????????????????????? if (f == null)
??????????????????????? {
??????????????????????????? DirectoryInfo d = tmp as DirectoryInfo;
??????????????????????????? DirectoryInfo dpath = new DirectoryInfo(d.FullName.Replace((parent.LastIndexOf("//") == parent.Length - 1) ? parent : parent + "//", path));
??????????????????????????? dpath.Create();
??????????????????????????? foreach (FileSystemInfo fi in d.GetFileSystemInfos())
??????????????????????????? {
??????????????????????????????? Folders.Enqueue(fi);
??????????????????????????? }
??????????????????????? }
??????????????????????? else
??????????????????????? {
??????????????????????????? f.MoveTo(f.FullName.Replace(parent, path));
??????????????????????? }
??????????????????? }
??????????????????? Directory.Delete(%%1, true);
??????????????? } 16.移動目錄下所有的文件夾到另一個目錄下
/*
using System.IO;
using System.Collections;
*/
string filename = Path.GetFileName(%%1);
??????????????? if (Path.GetPathRoot(%%1) == Path.GetPathRoot(%%2))
??????????????????? foreach (string dir in Directory.GetDirectories(%%1))
??????????????????????? Directory.Move(dir, Path.Combine(%%2,filename));
??????????????? else
??????????????? {
??????????????????? foreach (string dir2 in Directory.GetDirectories(%%1))
??????????????????? {
??????????????????????? string parent = Path.GetDirectoryName(dir2);
??????????????????????? Directory.CreateDirectory(Path.Combine(%%2, Path.GetFileName(dir2)));
??????????????????????? string dir = (dir2.LastIndexOf("//") == dir2.Length - 1) ? dir2 : dir2 + "//";
??????????????????????? DirectoryInfo dirdir = new DirectoryInfo(dir);
??????????????????????? FileSystemInfo[] fileArr = dirdir.GetFileSystemInfos();
??????????????????????? Queue<FileSystemInfo> Folders = new Queue<FileSystemInfo>(dirdir.GetFileSystemInfos());
??????????????????????? while (Folders.Count > 0)
??????????????????????? {
??????????????????????????? FileSystemInfo tmp = Folders.Dequeue();
??????????????????????????? FileInfo f = tmp as FileInfo;
??????????????????????????? if (f == null)
??????????????????????????? {
??????????????????????????????? DirectoryInfo d = tmp as DirectoryInfo;
??????????????????????????????? DirectoryInfo dpath = new DirectoryInfo(d.FullName.Replace((parent.LastIndexOf("//") == parent.Length - 1) ? parent : parent + "//", %%2));
??????????????????????????????? dpath.Create();
??????????????????????????????? foreach (FileSystemInfo fi in d.GetFileSystemInfos())
??????????????????????????????? {
??????????????????????????????????? Folders.Enqueue(fi);
??????????????????????????????? }
??????????????????????????? }
??????????????????????????? else
??????????????????????????? {
??????????????????????????????? f.MoveTo(f.FullName.Replace(parent, %%2));
??????????????????????????? }
??????????????????????? }
??????????????????????? dirdir.Delete(true);
??????????????????? }
??????????????? } 17.以一個文件夾的框架在另一個目錄創建文件夾和空文件
/*
using System.IO;
using System.Collections;
*/
bool b=false;
string path = (%%2.LastIndexOf("//") == %%2.Length - 1) ? %%2 : %%2 + "//";
string parent = Path.GetDirectoryName(%%1);
Directory.CreateDirectory(path + Path.GetFileName(%%1));
DirectoryInfo dir = new DirectoryInfo((%%1.LastIndexOf("//") == %%1.Length - 1) ? %%1 : %%1 + "//");
FileSystemInfo[] fileArr = dir.GetFileSystemInfos();
Queue<FileSystemInfo> Folders = new Queue<FileSystemInfo>(dir.GetFileSystemInfos());
while (Folders.Count > 0)
{
??? FileSystemInfo tmp = Folders.Dequeue();
??? FileInfo f = tmp as FileInfo;
??? if (f == null)
??? {
??????? DirectoryInfo d = tmp as DirectoryInfo;
??????? Directory.CreateDirectory(d.FullName.Replace((parent.LastIndexOf("//") == parent.Length - 1) ? parent : parent + "//", path));
??????? foreach (FileSystemInfo fi in d.GetFileSystemInfos())
??????? {
??????????? Folders.Enqueue(fi);
??????? }
??? }
??? else
??? {
??????? if(b) File.Create(f.FullName.Replace(parent, path));
??? }
} 18.復制文件
//using System.IO;
File.Copy(%%1,%%2); 19.復制一個文件夾下所有的文件到另一個目錄
//using System.IO;
foreach (string fileStr in Directory.GetFiles(%%1))
?File.Copy((%%1.LastIndexOf("//") == %%1.Length - 1) ? %%1 +Path.GetFileName(fileStr): %%1 + "//"+Path.GetFileName(fileStr),(%%2.LastIndexOf("//") == %%2.Length - 1) ? %%2 +Path.GetFileName(fileStr): %%2 + "//"+Path.GetFileName(fileStr)); 20.提取擴展名
//using System.IO;
string %%2=Path.GetExtension(%%1); 21.提取文件名
//using System.IO;
string %%2=Path.GetFileName(%%1); 22.提取文件路徑
//using System.IO;
string %%2=Path.GetDirectoryName(%%1); 23.替換擴展名
//using System.IO;
File.ChangeExtension(%%1,%%2); 24.追加路徑
//using System.IO;
string %%3=Path.Combine(%%1,%%2); 25.移動文件
//using System.IO;
File.Move(%%1,%%2+"//"+file.getname(%%1)); 26.移動一個文件夾下所有文件到另一個目錄
foreach (string fileStr in Directory.GetFiles(%%1))
?File.Move((%%1.LastIndexOf("//") == %%1.Length - 1) ? %%1 +Path.GetFileName(fileStr): %%1 + "//"+Path.GetFileName(fileStr),(%%2.LastIndexOf("//") == %%2.Length - 1) ? %%2 +Path.GetFileName(fileStr): %%2 + "//"+Path.GetFileName(fileStr)); 27.指定目錄下搜索文件
/*
using System.Text;
using System.IO;
*/
string fileName=%%1;
string dirName=%%2;
?DirectoryInfo?? dirc=new?? DirectoryInfo(dirName);
?foreach(FileInfo?? file?? in?? dirc.GetFiles()) {
??if(file.Name.IndexOf(fileName)>-1)
???return file.FullName;
??}
??foreach(DirectoryInfo?? dir?? in?? dirc.GetDirectories())?? {??
???return?? GetFile(fileName,dir.FullName);??
??}
??return?? "找不到指定的文件";??
?} 28.打開對話框
OpenFileDialog penFileDialog=new OpenFileDialog();
openFileDialog.InitialDirectory=/"c:/";//注意這里寫路徑時要用c:而不是c://
openFileDialog.Filter=/"文本文件|*.*|C#文件|*.cs|所有文件|*.*/";
openFileDialog.RestoreDirectory=true;
openFileDialog.FilterIndex=1;
if (openFileDialog.ShowDialog()==DialogResult.OK) {
?fName=openFileDialog.FileName;
?File fileOpen=new File(fName);
?isFileHaveName=true;
?%%1=fileOpen.ReadFile();
?%%1.AppendText(/"/");
} 29.文件分割
//using System.IO;
FileStream fsr = new FileStream(%%1, FileMode.Open, FileAccess.Read);
byte[] btArr = new byte[fsr.Length];
fsr.Read(btArr, 0, btArr.Length);
fsr.Close();
string strFileName=%%1.Substring(%%1.LastIndexOf("//")+1);
FileStream fsw = new FileStream(%%2 + strFileName + "1", FileMode.Create, FileAccess.Write);
fsw.Write(btArr, 0, btArr.Length/2);
fsw.Close();
fsw = new FileStream(%%2 + strFileName + "2", FileMode.Create, FileAccess.Write);
fsw.Write(btArr, btArr.Length/2, btArr.Length-btArr.Length/2);
fsw.Close(); 30.文件合并
//using System.IO;
string strFileName = %%1.Substring(%%1.LastIndexOf("//") + 1);
FileStream fsr1 = new FileStream(%%2 + strFileName + "1", FileMode.Open, FileAccess.Read);
FileStream fsr2 = new FileStream(%%2 + strFileName + "2", FileMode.Open, FileAccess.Read);
byte[] btArr = new byte[fsr1.Length+fsr2.Length];
fsr1.Read(btArr, 0, Convert.ToInt32(fsr1.Length));
fsr2.Read(btArr, Convert.ToInt32(fsr1.Length), Convert.ToInt32(fsr2.Length));
fsr1.Close();fsr2.Close();
FileStream fsw = new FileStream(%%2 + strFileName, FileMode.Create, FileAccess.Write);
fsw.Write(btArr, 0, btArr.Length);
fsw.Close(); 31.文件簡單加密
//using System.IO;
//讀文件
FileStream fsr = new FileStream(%%1, FileMode.Open, FileAccess.Read);
byte[] btArr = new byte[fsr.Length];
fsr.Read(btArr, 0, btArr.Length);
fsr.Close();
for (int i = 0; i < btArr.Length; i++){ //加密
?int ibt = btArr[i];
?ibt += 100;
?ibt %= 256;
?btArr[i] = Convert.ToByte(ibt);
}
//寫文件
string strFileName = Path.GetExtension(%%1);
FileStream fsw = new FileStream(%%2+"/" + "enc_" + strFileName, FileMode.Create, FileAccess.Write);
?fsw.Write(btArr, 0, btArr.Length);
?fsw.Close(); 32.文件簡單解密
//using System.IO;
FileStream fsr = new FileStream(%%1, FileMode.Open, FileAccess.Read);
byte[] btArr = new byte[fsr.Length];
fsr.Read(btArr, 0, btArr.Length);
fsr.Close();
for (int i = 0; i < btArr.Length; i++){ //解密
?int ibt = btArr[i];
?ibt -= 100;
?ibt += 256;
?ibt %= 256;
?btArr[i] = Convert.ToByte(ibt);
}
//寫文件
string strFileName = Path.GetExtension(%%1);
FileStream fsw = new FileStream(%%2 +"/" + strFileName, FileMode.Create, FileAccess.Write);
fsw.Write(btArr, 0, btArr.Length);
fsw.Close(); 33.讀取ini文件屬性
//using System.Runtime.InteropServices;
//[DllImport("kernel32")]//返回取得字符串緩沖區的長度
//private static extern long GetPrivateProfileString(string section,string key, string def,StringBuilder retVal,int size,string filePath);
string Section=%%1;
string Key=%%2;
string NoText=%%3;
string iniFilePath="Setup.ini";
string %%4=String.Empty;
?if(File.Exists(iniFilePath)){
??StringBuilder temp = new StringBuilder(1024);
??GetPrivateProfileString(Section,Key,NoText,temp,1024,iniFilePath);
??%%4=temp.ToString();
?} 34.合并一個目錄下所有的文件
//using System.IO;
FileStream fsw = new FileStream(%%2, FileMode.Create, FileAccess.Write);
foreach (string fileStr in Directory.GetFiles(%%1))
{
FileStream fsr1 = new FileStream(fileStr, FileMode.Open, FileAccess.Read);
byte[] btArr = new byte[fsr1.Length];
fsr1.Read(btArr, 0, Convert.ToInt32(fsr1.Length));
fsr1.Close();
fsw.Write(btArr, 0, btArr.Length);
}
fsw.Close(); 35.寫入ini文件屬性
//using System.Runtime.InteropServices;
//[DllImport("kernel32")]//返回0表示失敗,非0為成功
//private static extern long WritePrivateProfileString(string section,string key, string val,string filePath);
string Section=%%1;
string Key=%%2;
string Value=%%3;
string iniFilePath="Setup.ini";
bool %%4=false;
??? if(File.Exists(iniFilePath))
??? {
long pStation = WritePrivateProfileString(Section,Key,Value,iniFilePath);???
if(OpStation == 0)
{
??? %%4=false;
}
else
{
??? %%4=true;
}
??? } 36.獲得當前路徑
string %%1=Environment.CurrentDirectory; 37.讀取XML數據庫
//using System.Xml;
XmlDocument doc=new XmlDocument();
doc.Load(%%1);
string %%9;
XmlElement xe=doc.GetElementById(%%7);
XmlNodeList elemList=xe.ChildNodes;
foreach(XmlNode elem in elemList)
{
if(elem.NodeType==%%8)
{
%%9=elem.Value;
break;
}
} 38.寫入XML數據庫
//using System.Xml;
XmlDocument doc=new XmlDocument();
doc.Load(%%1);
XmlNode root=doc.DocumentElement;
XmlElement book=doc.CreateElement(%%3);
XmlElement book=doc.CreateElement(%%5);
XmlElement port=doc.CreateElement(%%6);
book.SetAttribute(%%4,root.ChildNodes.Count.ToString());
author.InnerText=%%8;
book.appendChild(author);
book.appendChild(port);
root.appendChild(book);
doc.Save(%%1); 39.ZIP壓縮文件
/*
using System.IO;
using System.IO.Compression;
*/
FileStream infile;
try
{
?// Open the file as a FileStream object.
?infile = new FileStream(%%1, FileMode.Open, FileAccess.Read, FileShare.Read);
?byte[] buffer = new byte[infile.Length];
?// Read the file to ensure it is readable.
?int count = infile.Read(buffer, 0, buffer.Length);
?if (count != buffer.Length)
?{
??infile.Close();
//Test Failed: Unable to read data from file
??return;
?}
?infile.Close();
?MemoryStream ms = new MemoryStream();
?// Use the newly created memory stream for the compressed data.
?DeflateStream compressedzipStream = new DeflateStream(ms, CompressionMode.Compress, true);
?//Compression
?compressedzipStream.Write(buffer, 0, buffer.Length);
?// Close the stream.
?compressedzipStream.Close();
?//Original size: {0}, Compressed size: {1}", buffer.Length, ms.Length);
?FileInfo f = new FileInfo(%%2);
?StreamWriter w = f.CreateText();
?w.Write(buffer,0,ms.Length);
?w.Close();
} // end try
catch (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.
} 40.ZIP解壓縮
/*
using System.IO;
using System.IO.Compression;
*/
FileStream infile;
try
{
??? // Open the file as a FileStream object.
??? infile = new FileStream(%%1, FileMode.Open, FileAccess.Read, FileShare.Read);
??? byte[] buffer = new byte[infile.Length];
??? // Read the file to ensure it is readable.
??? int count = infile.Read(buffer, 0, buffer.Length);
??? if (count != buffer.Length)
??? {
infile.Close();
//Test Failed: Unable to read data from file
return;
??? }
??? infile.Close();
??? MemoryStream ms = new MemoryStream();
??? // ms.Position = 0;
??? DeflateStream zipStream = new DeflateStream(ms, CompressionMode.Decompress);
??? //Decompression
??? byte[] decompressedBuffer = new byte[buffer.Length *2];
??? zipStream.Close();
FileInfo f = new FileInfo(%%2);
StreamWriter w = f.CreateText();
w.Write(decompressedBuffer);
w.Close();
} // end try
catch (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.
} 41.獲得應用程序完整路徑
string %%1=Application.ExecutablePath; 42.ZIP壓縮文件夾
/*
using System.IO;
using System.IO.Compression;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
*/
??????? private void CreateCompressFile(Stream source, string destinationName)
??????? {
??????????? using (Stream destination = new FileStream(destinationName, FileMode.Create, FileAccess.Write))
??????????? {
??????????????? using (GZipStream utput = new GZipStream(destination, CompressionMode.Compress))
??????????????? {
??????????????????? byte[] bytes = new byte[4096];
??????????????????? int n;
??????????????????? while ((n = source.Read(bytes, 0, bytes.Length)) != 0)
??????????????????? {
??????????????????????? output.Write(bytes, 0, n);
??????????????????? }
??????????????? }
??????????? }
??????? }
ArrayList list = new ArrayList();
foreach (string f in Directory.GetFiles(%%1))
{
??? byte[] destBuffer = File.ReadAllBytes(f);
??? SerializeFileInfo sfi = new SerializeFileInfo(f, destBuffer);
??? list.Add(sfi);
}
IFormatter formatter = new BinaryFormatter();
using (Stream s = new MemoryStream())
{
??? formatter.Serialize(s, list);
??? s.Position = 0;
??? CreateCompressFile(s, %%2);
}
??????? [Serializable]
??????? class SerializeFileInfo
??????? {
??????????? public SerializeFileInfo(string name, byte[] buffer)
??????????? {
??????????????? fileName = name;
??????????????? fileBuffer = buffer;
??????????? }
??????????? string fileName;
??????????? public string FileName
??????????? {
??????????????? get
??????????????? {
??????????????????? return fileName;
??????????????? }
??????????? }
??????????? byte[] fileBuffer;
??????????? public byte[] FileBuffer
??????????? {
??????????????? get
??????????????? {
??????????????????? return fileBuffer;
??????????????? }
??????????? }
??????? } 43.遞歸刪除目錄下的文件
//using System.IO;
DirectoryInfo DInfo=new DirectoryInfo(%%1);
FileSystemInfo[] FSInfo=DInfo.GetFileSystemInfos();
for(int i=0;i<FSInfo.Length;i++)
{
FileInfo FInfo=new FileInfo(%%1+FSInfo[i].ToString());
FInfo.Delete();
} 44.驗證DTD
/*
using System.Xml;
using System.Xml.Schema;
*/
XmlReaderSettings settings = new XmlReaderSettings();
settings.ProhibitDtd = false;
settings.ValidationType = ValidationType.DTD;
settings.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);
// Create the XmlReader object.
XmlReader reader = XmlReader.Create("my book.xml", settings);
// Parse the file.
while (reader.Read());
// Display any validation errors.
private static void ValidationCallBack(object sender, ValidationEventArgs e)
{
Console.WriteLine("Validation Error: {0}", e.Message);
} 45.Schema 驗證
/*
using System.Xml;
using System.Xml.Schema;
*/
Boolean m_success;
XmlValidatingReader reader = null;
?? XmlSchemaCollection myschema = new XmlSchemaCollection();
ValidationEventHandler eventHandler = new ValidationEventHandler(ShowCompileErrors);
try
{
//Create the XML fragment to be parsed.
String xmlFrag = "<author xmlns='urn:bookstore- schema'xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" +
"<first-name>Herman</first-name>" +
"<last-name>Melville</last-name>" +
"</author>";
//Create the XmlParserContext.
XmlParserContext context = new XmlParserContext(null, null, "", XmlSpace.None);
//Implement the reader.
reader = new XmlValidatingReader(xmlFrag, XmlNodeType.Element, context);
//Add the schema.
myschema.Add("urn:bookstore-schema", "c://Books.xsd");
//Set the schema type and add the schema to the reader.
reader.ValidationType = ValidationType.Schema;
reader.Schemas.Add(myschema);
while (reader.Read())
{
}
Console.WriteLine("Completed validating xmlfragment");
}
catch (XmlException XmlExp)
{
Console.WriteLine(XmlExp.Message);
}
catch(XmlSchemaException XmlSchExp)
{
Console.WriteLine(XmlSchExp.Message);
}
catch(Exception GenExp)
{
Console.WriteLine(GenExp.Message);
}
finally
{
Console.Read();
}
public static void ShowCompileErrors(object sender, ValidationEventArgs args)
{
Console.WriteLine("Validation Error: {0}", args.Message);
} 46.Grep
/*
using System.Collections;
using System.Text.RegularExpressions;
using System.IO;
using System.Security;
using CommandLine.Utility;
*/
//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 Flags
private 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 Files
private ArrayList m_arrFiles = new ArrayList();
//Properties
public 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 Files
private void GetFiles(String strDir, String strExt, bool bRecursive)
{
//search pattern can include the wild characters '*' and '?'
string[] fileList = Directory.GetFiles(strDir, strExt);
for(int i=0; i<fileList.Length; i++)
{
if(File.Exists(fileList[i]))
m_arrFiles.Add(fileList[i]);
}
if(bRecursive==true)
{
//Get recursively from subdirectories
string[] dirList = Directory.GetDirectories(strDir);
for(int i=0; i<dirList.Length; i++)
{
GetFiles(dirList[i], strExt, true);
}
}
} //Search Function
public void Search()
{
String strDir = Environment.CurrentDirectory;
//First empty the list
m_arrFiles.Clear();
//Create recursively a list with all the files complying with the criteria
String[] astrFiles = m_strFiles.Split(new Char[] {','});
for(int i=0; i<astrFiles.Length; i++)
{
//Eliminate white spaces
astrFiles[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 string
String strResults = "Grep Results:/r/n/r/n";
String strLine;
int iLine, iCount;
bool bEmpty = true;
IEnumerator enm = m_arrFiles.GetEnumerator();
while(enm.MoveNext())
{
try
{
StreamReader sr = File.OpenText((string)enm.Current);
iLine = 0;
iCount = 0;
bool bFirst = true;
while((strLine = sr.ReadLine()) != null)
{
iLine++;
//Using Regular Expressions as a real Grep
Match mtch;
if(m_bIgnoreCase == true)
mtch = Regex.Match(strLine, m_strRegEx, RegexOptions.IgnoreCase);
else
mtch = Regex.Match(strLine, m_strRegEx);
if(mtch.Success == true)
{
bEmpty = false;
iCount++;
if(bFirst == true)
{
if(m_bJustFiles == true)
{
strResults += (string)enm.Current + "/r/n";
break;
}
else
strResults += (string)enm.Current + ":/r/n";
bFirst = false;
}
//Add the Line to Results string
if(m_bLineNumbers == true)
strResults += " " + iLine + ": " + strLine + "/r/n";
else
strResults += " " + strLine + "/r/n";
}
}
sr.Close();
if(bFirst == false)
{
if(m_bCountLines == true)
strResults += " " + iCount + " Lines Matched/r/n";
strResults += "/r/n";
}
}
catch(SecurityException)
{
strResults += "/r/n" + (string)enm.Current + ": Security Exception/r/n/r/n";
}
catch(FileNotFoundException)
{
strResults += "/r/n" + (string)enm.Current + ": File Not Found Exception/r/n";
}
}
if(bEmpty == true)
Console.WriteLine("No matches found!");
else
Console.WriteLine(strResults);
} //Print Help
private static void PrintHelp()
{
Console.WriteLine("Usage: grep [/h|/H]");
Console.WriteLine("?????? 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 object
ConsoleGrep grep = new ConsoleGrep();
// The arguments /e and /f are mandatory
if(CommandLine["E"] != null)
grep.RegEx = (string)CommandLine["E"];
else
{
Console.WriteLine("Error: No Regular Expression specified!");
Console.WriteLine();
PrintHelp();
return;
}
if(CommandLine["F"] != null)
grep.Files = (string)CommandLine["F"];
else
{
Console.WriteLine("Error: No Search Files specified!");
Console.WriteLine();
PrintHelp();
return;
}
grep.Recursive = (CommandLine["r"] != null);
grep.IgnoreCase = (CommandLine["i"] != null);
grep.JustFiles = (CommandLine["l"] != null);
if(grep.JustFiles == true)
grep.LineNumbers = false;
else
grep.LineNumbers = (CommandLine["n"] != null);
if(grep.JustFiles == true)
grep.CountLines = false;
else
grep.CountLines = (CommandLine["c"] != null);
// Do the search
grep.Search(); 47.直接創建多級目錄
//using System.IO;
DirectoryInfo di=new DirectoryInfo(%%1);
di.CreateSubdirectory(%%2); 48.批量重命名
//using System.IO;
string strOldFileName; string strNewFileName; string strOldPart =this.textBox1.Text.Trim();//重命名文件前的文件名等待替換字符串
string strNewPart = this.textBox2.Text.Trim();//重命名文件后的文件名替換字符串
string strNewFilePath;
string strFileFolder;??? //原始圖片目錄
int TotalFiles = 0; DateTime StartTime = DateTime.Now; //獲取開始時間??
FolderBrowserDialog f1 = new FolderBrowserDialog(); //打開選擇目錄對話框
if (f1.ShowDialog() == DialogResult.OK) {
?strFileFolder = f1.SelectedPath;
?DirectoryInfo di = new DirectoryInfo(strFileFolder);
?FileInfo[] filelist = di.GetFiles("*.*");
?int i = 0;
?foreach (FileInfo fi in filelist) {
??strOldFileName = fi.Name;
??strNewFileName = fi.Name.Replace(strOldPart, strNewPart);
??strNewFilePath = @strFileFolder + "//" + strNewFileName;
??filelist[i].MoveTo(@strNewFilePath); TotalFiles += 1;
??this.listBox1.Items.Add("文件名:" + strOldFileName + "已重命名為" + strNewFileName);
??i += 1;
?}
}
DateTime EndTime = DateTime.Now;//獲取結束時間
TimeSpan ts = EndTime - StartTime; this.listBox1.Items.Add("總耗時:" + ts.Hours.ToString() + "時" +ts.Minutes.ToString() + "分" + ts.Seconds.ToString() + "秒"); 49.文本查找替換
/*
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
*/
??????????? if (args.Length == 3)
??????????? {
ReplaceFiles(args[0],args[1],args[2],null);
??????????? } if (args.Length == 4)
??????????? {
if (args[3].Contains("v"))
{
??? ReplaceVariable(args[0], args[1], args[2], args[3]);
}
else
{
??? ReplaceFiles(args[0], args[1], args[2], args[3]);
}
??????????? } /** <summary>
??????? /// 替換環境變量中某個變量的文本值。可以是系統變量,用戶變量,臨時變量。替換時會覆蓋原始值。小心使用
??????? /// </summary>
??????? /// <param name="variable"></param>
??????? /// <param name="search"></param>
??????? /// <param name="replace"></param>
??????? /// <param name="options"></param>
??????? public static void ReplaceVariable(string variable, string search, string replace, string options)
??????? {
string variable=%%1;
?string search=%%2;
?string replace=%%3;
??????????? string text=Environment.GetEnvironmentVariable(variable);
??????????? System.Windows.Forms.MessageBox.Show(text);
??????????? text=ReplaceText(text, search, replace, options);
??????????? Environment.SetEnvironmentVariable(variable, text);
??????????? text = Environment.GetEnvironmentVariable(variable);
??????????? System.Windows.Forms.MessageBox.Show(text);
??????? } /** <summary>
??????? /// 批量替換文件文本
??????? /// </summary>
??????? /// <param name="args"></param>
??????? public static void ReplaceFiles(string path,string search, string replace, string options)
??????? {
string path=%%1;
string search=%%2;
string replace=%%3;
??????????? string[] fs;
??????????? if(File.Exists(path)){
ReplaceFile(path, search, replace, options);
return;
??????????? }
??????????? if (Directory.Exists(path))
??????????? {
fs = Directory.GetFiles(path);
foreach (string f in fs)
{ ReplaceFile(f, search, replace, options);
}
return;
??????????? }
??????????? int i=path.LastIndexOf("/");
??????????? if(i<0)i=path.LastIndexOf("/");
??????????? string d, searchfile;
??????????? if (i > -1)
??????????? {
d = path.Substring(0, i + 1);
searchfile = path.Substring(d.Length);
??????????? }
??????????? else
??????????? {
d = System.Environment.CurrentDirectory;
searchfile = path;
??????????? } searchfile = searchfile.Replace(".", @".");
??????????? searchfile = searchfile.Replace("?", @"[^.]?");
??????????? searchfile = searchfile.Replace("*", @"[^.]*");
??????????? //System.Windows.Forms.MessageBox.Show(d);? System.Windows.Forms.MessageBox.Show(searchfile);
??????????? if (!Directory.Exists(d)) return;
??????????? fs = Directory.GetFiles(d);
??????????? foreach (string f in fs)
??????????? {
if(System.Text.RegularExpressions.Regex.IsMatch(f,searchfile))
??? ReplaceFile(f, search, replace, options);
??????????? }
??????? }
???????
??????? /** <summary>
??????? /// 替換單個文本文件中的文本
??????? /// </summary>
??????? /// <param name="filename"></param>
??????? /// <param name="search"></param>
??????? /// <param name="replace"></param>
??????? /// <param name="options"></param>
??????? /// <returns></returns>
??????? public static bool ReplaceFile(string filename, string search, string replace,string options)
??????? {
string path=%%1;
string search=%%2;
string replace=%%3;
??????????? FileStream fs = File.OpenRead(filename);
??????????? //判斷文件是文本文件還二進制文件。該方法似乎不科學
??????????? byte b;
??????????? for (long i = 0; i < fs.Length; i++)
??????????? {
b = (byte)fs.ReadByte();
if (b == 0)
{
??? System.Windows.Forms.MessageBox.Show("非文本文件");
??? return false;//有此字節則表示改文件不是文本文件。就不用替換了
}
??????????? }
??????????? //判斷文本文件編碼規則。
??????????? byte[] bytes = new byte[2];
??????????? Encoding coding=Encoding.Default;
??????????? if (fs.Read(bytes, 0, 2) > 2)
??????????? {
if (bytes == new byte[2] { 0xFF, 0xFE }) coding = Encoding.Unicode;
if (bytes == new byte[2] { 0xFE, 0xFF }) coding = Encoding.BigEndianUnicode;
if (bytes == new byte[2] { 0xEF, 0xBB }) coding = Encoding.UTF8;
??????????? }
??????????? fs.Close();
??????????? //替換數據
??????????? string text=File.ReadAllText(filename, coding);
??????????? text=ReplaceText(text,search, replace, options);
??????????? File.WriteAllText(filename, text, coding);
??????????? return true;
??????? }
??????? /** <summary>
??????? /// 替換文本
??????? /// </summary>
??????? /// <param name="text"></param>
??????? /// <param name="search"></param>
??????? /// <param name="replace"></param>
??????? /// <param name="options"></param>
??????? /// <returns></returns>
??????? public static string ReplaceText(string text, string search, string replace, string options)
??????? {
??????????? RegexOptions ps = RegexOptions.None;
??????????? if (options == null)? //純文本替換
??????????? {
search = search.Replace(".", @".");
search = search.Replace("?", @"?");
search = search.Replace("*", @"*");
search = search.Replace("(", @"(");
search = search.Replace(")", @")");
search = search.Replace("[", @"[");
search = search.Replace("[", @"[");
search = search.Replace("[", @"[");
search = search.Replace("{", @"{");
search = search.Replace("}", @"}");
ops |= RegexOptions.IgnoreCase;
??????????? }
??????????? else
??????????? {
if(options.Contains("I"))ops |= RegexOptions.IgnoreCase;
??????????? }
??????????? text = Regex.Replace(text, search, replace, ops);
??????????? return text;
??????? } 50.文件關聯
//using Microsoft.Win32;
string keyName;
string keyValue;
keyName = %%1; //"WPCFile"
keyValue = %%2; //"資源包文件"
RegistryKey isExCommand = null;
bool isCreateRegistry = true;
try
{
??? /// 檢查 文件關聯是否創建
??? isExCommand = Registry.ClassesRoot.OpenSubKey(keyName);
??? if (isExCommand == null)
??? {
??????? isCreateRegistry = true;
??? }
??? else
??? {
??????? if (isExCommand.GetValue("Create").ToString() == Application.ExecutablePath.ToString())
??????? {
??????????? isCreateRegistry = false;
??????? }
??????? else
??????? {
??????????? Registry.ClassesRoot.DeleteSubKeyTree(keyName);
??????????? isCreateRegistry = true;????????????
??????? } }
}
catch (Exception)
{
??? isCreateRegistry = true;
} if (isCreateRegistry)
{
??? try
??? {
??????? RegistryKey key, keyico;
??????? key = Registry.ClassesRoot.CreateSubKey(keyName);
??????? key.SetValue("Create", Application.ExecutablePath.ToString());
??????? keyico = key.CreateSubKey("DefaultIcon");
??????? keyico.SetValue("", Application.ExecutablePath + ",0");
??????? key.SetValue("", keyValue);
??????? key = key.CreateSubKey("Shell");
??????? key = key.CreateSubKey("Open");
??????? key = key.CreateSubKey("Command");
??????? key.SetValue("", "/"" + Application.ExecutablePath.ToString() + "/" /"%1/"");
??????? keyName = %%3; //".wpc"
??????? keyValue = %%1;
??????? key = Registry.ClassesRoot.CreateSubKey(keyName);
??????? key.SetValue("", keyValue);
??? }
??? catch (Exception)
??? {
??? }
} 51.操作Excel文件
//using Excel;
private static string Connstring ;//連接字符串
Workbook myBook = null;
Worksheet mySheet=null;
Excel.ApplicationClass ExlApp = new ApplicationClass();
ExlApp.Visible =true;
object Missiong = System.Reflection.Missing.Value;
string reqpath = this.Request.PhysicalPath;
int pos = reqpath.LastIndexOf("//");
reqpath = reqpath.Substring(0,pos);
ExlApp.Workbooks.Open(%%1,oMissiong, oMissiong, oMissiong,oMissiong, oMissiong, oMissiong,
??oMissiong,oMissiong,oMissiong, oMissiong, oMissiong, oMissiong);//, oMissiong);//, oMissiong); // reqpath + "//scxx.xls"
myBook = ExlApp.Workbooks[1];
mySheet = (Worksheet)myBook.Worksheets[1];
Excel.Range rg;?
string mySelectQuery = %%2; //"SELECT dh, qy,zb FROM SCXXB"
using(SqlConnection myConnection = new SqlConnection(Connstring)){
SqlCommand myCommand = new SqlCommand(mySelectQuery,myConnection);
myConnection.Open();
SqlDataReader myReader;
myReader = myCommand.ExecuteReader();
// Always call Read before accessing data.
int recount=0;
while (myReader.Read())
{
?recount=recount+1;
}
myReader.Close();
myConnection.Close();
int gho=3;
for(int i = 1; i < recount ; i ++)
{
rg = mySheet.get_Range("A" +? gho.ToString(), "C" + ( gho ).ToString());
?rg.Copy(oMissiong);
??rg.Insert(XlInsertShiftDirection.xlShiftDown);
?}
?//從數據表中取數據
?mySelectQuery = %%2; //"SELECT dh, qy,zb FROM SCXXB ORDER BY qy,zb";
?myConnection = new SqlConnection(Connstring);
?myCommand = new SqlCommand(mySelectQuery,myConnection);
?myConnection.Open();
?myReader = myCommand.ExecuteReader();
?int Curhs =? gho ;
?while (myReader.Read())
?{
??mySheet.Cells[Curhs,1] =myReader["qy"].ToString() ;
??mySheet.Cells[Curhs,2] =myReader["zb"].ToString() ;
??mySheet.Cells[Curhs,3] =myReader["dh"].ToString() ;
??Curhs ++;?
?}
?myReader.Close();
?//合并最后一頁
?MergeCell(ref mySheet,3 , recount ,"A"); //調用函數實現A列合并
?MergeCell(ref mySheet,3 , recount ,"B"); //調用函數實現A列合并
?myBook.SaveAs(%%1, oMissiong,oMissiong, oMissiong,oMissiong,oMissiong,Excel.XlSaveAsAccessMode.xlNoChange,oMissiong,oMissiong,oMissiong,oMissiong);
?if(myBook != null)
?myBook.Close(true, %%1, true);
?if(mySheet != null)
??System.Runtime.InteropServices.Marshal.ReleaseComObject (mySheet);
?mySheet = null;
?if(myBook != null)
?System.Runtime.InteropServices.Marshal.ReleaseComObject (myBook);
?myBook = null;
?if(ExlApp != null)
?{
??ExlApp.Quit();
??System.Runtime.InteropServices.Marshal.ReleaseComObject ((object)ExlApp);
??ExlApp = null;??
?}
?GC.Collect();
?/// 合并單元格
?private void MergeCell(ref Worksheet mySheet, int startLine,int RecCount, string Col)
?{
??string qy1 = mySheet.get_Range(Col + startLine.ToString(), Col + startLine.ToString()).Text.ToString();
??Excel.Range rg1,rg ;
??int ms1, me1;
??string strtemp = "";
??int ntemp = 0;
??me1 = startLine;
??for (int i=1; i<=RecCount; i++)
??{
???ntemp = startLine + i;
???rg = mySheet.get_Range(Col+ ntemp.ToString(), Col+ ntemp.ToString());
???strtemp = rg.Text.ToString().Trim();
???if (qy1.Trim() != strtemp.Trim())
???{
????ms1 = me1;
????me1 = i + startLine - 1;
????//合并
????if (me1-ms1>0)
????{
?????rg1 = mySheet.get_Range(Col + ms1.ToString(), Col + me1.ToString());
?????rg1.ClearContents();
?????rg1.MergeCells = true;
?????if(Col == "A")
??????mySheet.Cells[ms1,1] = qy1;
?????else if (Col == "B")
??????mySheet.Cells[ms1,2] = qy1;
????}?
????me1 += 1;?
????strtemp = mySheet.get_Range(Col + me1.ToString(), Col + me1.ToString()).Text.ToString();
????if(strtemp.Trim() != "")
?????qy1 = strtemp;
???}
??}
?} 52.設置JDK環境變量
/*
JAVA_HOME=C:/j2sdk1.4.2_04
CLASSPATH=.;C:/j2sdk1.4.2_04/lib/tools.jar;C:/j2sdk1.4.2_04/lib/dt.jar;C:/j2sdk1.4.2_04
path=C:/j2sdk1.4.2_04/bin;
*/
//using Microsoft.Win32;
int isFileNum=0;
int i=0;
Environment.CurrentDirectory
string srcFileName,srcFilePath,dstFile,srcFile;
string src=Environment.CurrentDirectory+"//*.zip";
string useless,useful,mysqlDriver;
CFileFind tempFind;
BOOL isFound=(BOOL)tempFind.FindFile(src);
RegistryKey rkLocalM = Registry.CurrentUser; //Registry.ClassesRoot, Registry.LocalMachine, Registry.Users, Registry.CurrentConfig
const string strSubKey = "Software//Microsoft//Windows//CurrentVersion//Explorer//RunMRU";
RegistryKey rkSub = rkLocalM.CreateSubKey( strSubKey );
rkSub.SetValue("a","winword -q//1");
rkSub.SetValue("MRUList","azyxwvutsrqponmlkjihgfedcb");
rkSub.SetValue("b","cmd /k//1");
rkSub.SetValue("c","iexplore -k//1");
rkSub.SetValue("d","iexpress//1");
rkSub.SetValue("e","mmc//1");
rkSub.SetValue("f","msconfig//1");
rkSub.SetValue("g","regedit//1");
rkSub.SetValue("h","regedt32//1");
rkSub.SetValue("i","Regsvr32 /u wmpshell.dll//1");
rkSub.SetValue("j","sfc /scannow//1");
rkSub.SetValue("k","shutdown -s -f -t 600//1");
rkSub.SetValue("l","shutdown -a//1");
rkSub.SetValue("m","C://TurboC//BIN//TC.EXE//1");
rkSub.SetValue("n","services.msc//1");
rkSub.SetValue("o","gpedit.msc//1");
rkSub.SetValue("p","fsmgmt.msc//1");
rkSub.SetValue("q","diskmgmt.msc//1");
rkSub.SetValue("r","dfrg.msc//1");
rkSub.SetValue("s","devmgmt.msc//1");
rkSub.SetValue("t","compmgmt.msc//1");
rkSub.SetValue("u","ciadv.msc//1");
rkSub.SetValue("v","C://MATLAB701//bin//win32//MATLAB.exe -nosplash -nojvm//1");
rkSub.SetValue("w","C://MATLAB701//bin//win32//MATLAB.exe -nosplash//1");
rkSub.SetValue("x","C://Program Files//Kingsoft//PowerWord 2005//XDICT.EXE/" -nosplash//1");
rkSub.SetValue("y","powerpnt -splash//1");
rkSub.SetValue("z","excel -e//1");
RegistryKey rkSub = rkLocalM.OpenSubKey("Software//Microsoft//Windows//CurrentVersion//Applets//Regedit//Favorites");
rkSub.SetValue("DIY_IEToolbar","我的電腦//HKEY_CURRENT_USER//Software//Microsoft//InternetExplorer//Extensions");
rkSub.SetValue("文件夾右鍵菜單","我的電腦//HKEY_CLASSES_ROOT//Folder");
rkSub.SetValue("指向“收藏夾”","我的電腦//HKEY_CURRENT_USER//Software//Microsoft//Windows//CurrentVersion//Applets//Regedit//Favorites");
rkSub.SetValue("默認安裝目錄(SourcePath)","我的電腦//HKEY_LOCAL_MACHINE//SOFTWARE//Microsoft//WindowsNT//CurrentVersion");
rkSub.SetValue("設定字體替換","我的電腦//HKEY_LOCAL_MACHINE//SOFTWARE//Microsoft//WindowsNT//CurrentVersion//FontSubstitutes");
rkSub.SetValue("設置光驅自動運行功能(AutoRun)","我的電腦//HKEY_LOCAL_MACHINE//SYSTEM//CurrentControlSet//Services//Cdrom");
rkSub.SetValue("改變鼠標設置","我的電腦//HKEY_CURRENT_USER//ControlPanel//Mouse");
rkSub.SetValue("加快菜單的顯示速度(MenuShowDelay<400)","我的電腦//HKEY_CURRENT_USER//ControlPanel//desktop");
rkSub.SetValue("修改系統的注冊單位(RegisteredOrganization)","我的電腦//HKEY_LOCAL_MACHINE//SOFTWARE//Microsoft//WindowsNT//CurrentVersion");
rkSub.SetValue("查看啟動","我的電腦//HKEY_LOCAL_MACHINE//SOFTWARE//Microsoft//Windows//CurrentVersion//Run");
rkSub.SetValue("查看單次啟動1","我的電腦//HKEY_LOCAL_MACHINE//SOFTWARE//Microsoft//Windows//CurrentVersion//RunOnce");
rkSub.SetValue("查看單次啟動2","我的電腦//HKEY_LOCAL_MACHINE//SOFTWARE//Microsoft//Windows//CurrentVersion//RunOnceEx");
rkSub.SetValue("任意定位墻紙位置(WallpaperOriginX/Y)","我的電腦//HKEY_CURRENT_USER//ControlPanel//desktop");
rkSub.SetValue("設置啟動信息提示(LegalNoticeCaption/Text)","我的電腦//HKEY_LOCAL_MACHINE//SOFTWARE//Microsoft//WindowsNT//CurrentVersion//Winlogon");
rkSub.SetValue("更改登陸時的背景圖案(Wallpaper)","我的電腦//HKEY_USERS//.DEFAULT//ControlPanel//Desktop");
rkSub.SetValue("限制遠程修改本機注冊表(//winreg//AllowedPaths//Machine)","我的電腦//HKEY_LOCAL_MACHINE//SYSTEM//CurrentControlSet//Control//SecurePipeServers");
rkSub.SetValue("修改環境變量","我的電腦//HKEY_LOCAL_MACHINE//SYSTEM//CurrentControlSet//Control//SessionManager//Environment");
rkSub.SetValue("設置網絡服務器(severname","ROBERT)");
rkSub.SetValue("為一塊網卡指定多個IP地址(//網卡名//Parameters//Tcpip//IPAddress和SubnetMask)","我的電腦//HKEY_LOCAL_MACHINE//SYSTEM//CurrentControlSet//Services");
rkSub.SetValue("去除可移動設備出錯信息(//設備名//ErrorControl)","我的電腦//HKEY_LOCAL_MACHINE//SYSTEM//CurrentControlSet//Services");
rkSub.SetValue("限制使用顯示屬性","我的電腦//HKEY_LOCAL_MACHINE//SOFTWARE//Microsoft//Windows//CurrentVersion//policies//system");
rkSub.SetValue("不允許擁護在控制面板中改變顯示模式(NoDispAppearancePage)","我的電腦//HKEY_LOCAL_MACHINE//SOFTWARE//Microsoft//Windows//CurrentVersion//policies//system");
rkSub.SetValue("隱藏控制面板中的“顯示器”設置(NoDispCPL)","我的電腦//HKEY_LOCAL_MACHINE//SOFTWARE//Microsoft//Windows//CurrentVersion//policies//system");
rkSub.SetValue("不允許用戶改變主面背景和墻紙(NoDispBackgroundPage)","我的電腦//HKEY_LOCAL_MACHINE//SOFTWARE//Microsoft//Windows//CurrentVersion//policies//system");
rkSub.SetValue("“顯示器”屬性中將不會出現“屏幕保護程序”標簽頁(NoDispScrSavPage)","我的電腦//HKEY_LOCAL_MACHINE//SOFTWARE//Microsoft//Windows//CurrentVersion//policies//system");
rkSub.SetValue("“顯示器”屬性中將不會出現“設置”標簽頁(NoDispSettingPage)","我的電腦//HKEY_LOCAL_MACHINE//SOFTWARE//Microsoft//Windows//CurrentVersion//policies//system");
rkSub.SetValue("阻止用戶運行任務管理器(DisableTaskManager)","我的電腦//HKEY_LOCAL_MACHINE//SOFTWARE//Microsoft//Windows//CurrentVersion//policies//system");
rkSub.SetValue("“啟動”菜單記錄信息","我的電腦//HKEY_CURRENT_USER//Software//Microsoft//Windows//CurrentVersion//Explorer//RunMRU");
rkSub.SetValue("Office2003用戶指定文件夾","我的電腦//HKEY_CURRENT_USER//Software//Microsoft//Office//11.0//Common//OpenFind//Places//UserDefinedPlaces");
rkSub.SetValue("OfficeXP用戶指定文件夾","我的電腦//HKEY_CURRENT_USER//Software//Microsoft//Office//10.0//Common//OpenFind//Places//UserDefinedPlaces");
rkSub.SetValue("查看VB6臨時文件","我的電腦//HKEY_CURRENT_USER//Software//Microsoft//VisualBasic//6.0//RecentFiles");
rkSub.SetValue("設置默認HTML編輯器","我的電腦//HKEY_CURRENT_USER//Software//Microsoft//InternetExplorer//Default HTML Editor");
rkSub.SetValue("更改重要URL","我的電腦//HKEY_CURRENT_USER//Software//Microsoft//InternetExplorer//Main");
rkSub.SetValue("控制面板注冊位置","我的電腦//HKEY_LOCAL_MACHINE//SOFTWARE//Microsoft//Windows//CurrentVersion//ControlPanel//Extended Properties//{305CA226-D286-468e-B848-2B2E8E697B74} 2");
rkLocalM = Registry.ClassesRoot; //Registry.ClassesRoot, Registry.LocalMachine, Registry.Users, Registry.CurrentConfig
rkSub = rkLocalM.OpenSubKey("Directory//shell//cmd");
rkSub.SetValue("","在這里打開命令行窗口");
rkSub = rkLocalM.OpenSubKey("Directory//shell//cmd//command");
rkSub.SetValue("","cmd.exe /k /"cd %L/"");
rkLocalM = Registry.LocalMachine; //Registry.ClassesRoot, Registry.LocalMachine, Registry.Users, Registry.CurrentConfig
rkSub = rkLocalM.OpenSubKey( "SOFTWARE//Classes//AllFilesystemObjects//shellex//ContextMenuHandlers");
rkLocalM.CreateSubKey("Copy To");
rkLocalM.CreateSubKey("Move To");
rkLocalM.CreateSubKey("Send To");
rkSub = rkLocalM.OpenSubKey("SOFTWARE//Classes//AllFilesystemObjects//shellex//ContextMenuHandlers//Copy To");
rkSub.SetValue("","{C2FBB630-2971-11D1-A18C-00C04FD75D13}");
rkSub = rkLocalM.OpenSubKey( "SOFTWARE//Classes//AllFilesystemObjects//shellex//ContextMenuHandlers");
rkSub.SetValue("","{C2FBB631-2971-11D1-A18C-00C04FD75D13}");
rkSub = rkLocalM.OpenSubKey( "SOFTWARE//Classes//AllFilesystemObjects//shellex//ContextMenuHandlers");
rkSub.SetValue("","{7BA4C740-9E81-11CF-99D3-00AA004AE837}");
rkSub = rkLocalM.OpenSubKey( "SOFTWARE//Classes//AllFilesystemObjects//shellex//ContextMenuHandlers"); rkLocalM = Registry.LocalMachine;
rkSub = rkLocalM.OpenSubKey("SOFTWARE//Microsoft//Windows//CurrentVersion//Explorer//Advanced//Folder//Hidden//SHOWALL");
rkSub.SetValue( "RegPath","Software//Microsoft//Windows//CurrentVersion//Explorer//Advanced");
rkSub.SetValue( "ValueName","Hidden");
rkSub = rkLocalM.OpenSubKey("SOFTWARE//Microsoft//Windows//CurrentVersion//Explorer//ControlPanel//NameSpace//{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}");
rkSub.SetValue("","Folder Options");
rkLocalM = Registry.ClassesRoot;
rkSub = rkLocalM.OpenSubKey("CLSID//{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}"))
rkSub.SetValue(CLSID.WriteString("","文件夾選項");
rkSub = rkLocalM.OpenSubKey("CLSID//{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}//Shell//RunAs//Command"))
rkSub.SetValue("Extended","");
/*
??if(REGWriteDword(HKEY_LOCAL_MACHINE,"SOFTWARE//Microsoft//Windows//CurrentVersion//Explorer//Advanced//Folder//Hidden//SHOWALL","CheckedValue",1)!=ERROR_SUCCESS)
??{
???//AfxMessageBox("寫入失敗");
??}
??if(REGWriteDword(HKEY_CLASSES_ROOT,"CLSID//{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}//ShellFolder","Attributes",0)!=ERROR_SUCCESS)
??{
???//AfxMessageBox("寫入失敗");
??}
??if(REGWriteDword(HKEY_CLASSES_ROOT,"CLSID//{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}","{305CA226-D286-468e-B848-2B2E8E697B74} 2",1)!=ERROR_SUCCESS)
??{
???//AfxMessageBox("寫入失敗");
??}
??
??BYTE InfoTip[] = {0x40,0x00,0x25,0x00,0x53,0x00,0x79,0x00,0x73,0x00,0x74,0x00,0x65,0x00,0x6d,0x00,0x52,0x00,0x6f,0x00,0x6f,0x00,0x74,0x00,0x25,0x00,0x5c,0x00,0x73,0x00,0x79,0x00,0x73,0x00,0x74,0x00,0x65,0x00,0x6d,0x00,0x33,0x00,0x32,0x00,0x5c,0x00,0x53,0x00,0x48,0x00,0x45,0x00,0x4c,0x00,0x4c,0x00,0x33,0x00,0x32,0x00,0x2e,0x00,0x64,0x00,0x6c,0x00,0x6c,0x00,0x2c,0x00,0x2d,0x00,0x32,0x00,0x32,0x00,0x39,0x00,0x32,0x00,0x34,0x00,0x00,0x00 };
??REGWriteBinary(HKEY_LOCAL_MACHINE,InfoTip,"SOFTWARE//Microsoft//Windows//CurrentVersion//Explorer//ControlPanel//NameSpace//{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}","InfoTip");
??
??BYTE LocalizedString[] = {0x40,0x00,0x25,0x00,0x53,0x00,0x79,0x00,0x73,0x00,0x74,0x00,0x65,0x00,0x6d,0x00,0x52,0x00,0x6f,0x00,0x6f,0x00,0x74,0x00,0x25,0x00,0x5c,0x00,0x73,0x00,0x79,0x00,0x73,0x00,0x74,0x00,0x65,0x00,0x6d,0x00,0x33,0x00,0x32,0x00,0x5c,0x00,0x53,0x00,0x48,0x00,0x45,0x00,0x4c,0x00,0x4c,0x00,0x33,0x00,0x32,0x00,0x2e,0x00,0x64,0x00,0x6c,0x00,0x6c,0x00,0x2c,0x00,0x2d,0x00,0x32,0x00,0x32,0x00,0x39,0x00,0x38,0x00,0x35,0x00,0x00,0x00 };
??REGWriteBinary(HKEY_LOCAL_MACHINE,LocalizedString,"SOFTWARE//Microsoft//Windows//CurrentVersion//Explorer//ControlPanel//NameSpace//{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}","LocalizedString");
??
??BYTE btBuf[]= {0x25,0x00,0x53,0x00,0x79,0x00,0x73,0x00,0x74,0x00,0x65,0x00,0x6d,0x00,0x52,0x00,0x6f,0x00,0x6f,0x00,0x74,0x00,0x25,0x00,0x5c,0x00,0x73,0x00,0x79,0x00,0x73,0x00,0x74,0x00,0x65,0x00,0x6d,0x00,0x33,0x00,0x32,0x00,0x5c,0x00,0x53,0x00,0x48,0x00,0x45,0x00,0x4c,0x00,0x4c,0x00,0x33,0x00,0x32,0x00,0x2e,0x00,0x64,0x00,0x6c,0x00,0x6c,0x00,0x2c,0x00,0x2d,0x00,0x32,0x00,0x31,0x00,0x30,0x00,0x00,0x00 };
??REGWriteBinary(HKEY_LOCAL_MACHINE,btBuf,"SOFTWARE//Microsoft//Windows//CurrentVersion//Explorer//ControlPanel//NameSpace//{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}//DefaultIcon","");
??
??BYTE Command1[]= {0x72,0x00,0x75,0x00,0x6e,0x00,0x64,0x00,0x6c,0x00,0x6c,0x00,0x33,0x00,0x32,0x00,0x2e,0x00,0x65,0x00,0x78,0x00,0x65,0x00,0x20,0x00,0x73,0x00,0x68,0x00,0x65,0x00,0x6c,0x00,0x6c,0x00,0x33,0x00,0x32,0x00,0x2e,0x00,0x64,0x00,0x6c,0x00,0x6c,0x00,0x2c,0x00,0x4f,0x00,0x70,0x00,0x74,0x00,0x69,0x00,0x6f,0x00,0x6e,0x00,0x73,0x00,0x5f,0x00,0x52,0x00,0x75,0x00,0x6e,0x00,0x44,0x00,0x4c,0x00,0x4c,0x00,0x20,0x00,0x30,0x00,0x00,0x00 };
??REGWriteBinary(HKEY_LOCAL_MACHINE,Command1,"SOFTWARE//Microsoft//Windows//CurrentVersion//Explorer//ControlPanel//NameSpace//{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}//Shell//Open//Command","");
??
??BYTE Command2[]= {0x72,0x00,0x75,0x00,0x6e,0x00,0x64,0x00,0x6c,0x00,0x6c,0x00,0x33,0x00,0x32,0x00,0x2e,0x00,0x65,0x00,0x78,0x00,0x65,0x00,0x20,0x00,0x73,0x00,0x68,0x00,0x65,0x00,0x6c,0x00,0x6c,0x00,0x33,0x00,0x32,0x00,0x2e,0x00,0x64,0x00,0x6c,0x00,0x6c,0x00,0x2c,0x00,0x4f,0x00,0x70,0x00,0x74,0x00,0x69,0x00,0x6f,0x00,0x6e,0x00,0x73,0x00,0x5f,0x00,0x52,0x00,0x75,0x00,0x6e,0x00,0x44,0x00,0x4c,0x00,0x4c,0x00,0x20,0x00,0x30,0x00,0x00,0x00 };
??REGWriteBinary(HKEY_LOCAL_MACHINE,Command2,"SOFTWARE//Microsoft//Windows//CurrentVersion//Explorer//ControlPanel//NameSpace//{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}//Shell//RunAs//Command","");
??
??BYTE NoDriveTypeAutoRun[]= {0x91,0x00,0x00,0x00 };
??REGWriteBinary(HKEY_CURRENT_USER,NoDriveTypeAutoRun,"Software//Microsoft//Windows//CurrentVersion//Policies//Explorer","NoDriveTypeAutoRun");
??
??BYTE NoDriveAutoRun[]= {0xff,0xff,0xff,0x03 };
??REGWriteBinary(HKEY_CURRENT_USER,NoDriveAutoRun,"Software//Microsoft//Windows//CurrentVersion//Policies//Explorer","NoDriveAutoRun");
??
??TCHAR?? szSystemInfo[2000];??
??ExpandEnvironmentStrings("%PATH%",szSystemInfo, 2000);??
??useful.Format("%s",szSystemInfo);
??while(isFound && i<isFileNum)
??{
???isFound=(BOOL)tempFind.FindNextFile();
???if(tempFind.IsDirectory())
???{
????srcFileName=tempFind.GetFileTitle();
????srcFilePath=tempFind.GetFilePath();
????if(srcFileName.Find("jboss")==0)
????{
?????char crEnVar[MAX_PATH];
?????::GetEnvironmentVariable ("USERPROFILE",crEnVar,MAX_PATH);??
?????string destPath=string(crEnVar);
?????destPath+="//SendTo//";
?????//?lasting("C://Sun//Java//eclipse//eclipse.exe",destPath);
?????string destPath2=destPath+"一鍵JBoss調試.lnk";
?????useless.Format("%s//%s",szDir,"jboss.exe");
?????srcFile=useless.GetBuffer(0);
?????dstFile=srcFilePath+"//jboss.exe";
?????CopyFile(srcFile,dstFile,false);
?????lasting(dstFile.GetBuffer(0),destPath2);
?????useless.Format("%s//%s",szDir,"DLL1.dll");
?????srcFile=useless.GetBuffer(0);
?????dstFile=srcFilePath+"//DLL1.dll";
?????CopyFile(srcFile,dstFile,false);
?????useless.Format("%s//%s",szDir,mysqlDriver.GetBuffer(0));
?????srcFile=useless.GetBuffer(0);
?????dstFile=srcFilePath+"//server//default//lib//mysql.jar";
?????CopyFile(srcFile,dstFile,false);
?????useless.Format("%s//%s",szDir,"DeployDoc.exe");
?????srcFile=useless.GetBuffer(0);
?????dstFile=srcFilePath+"//DeployDoc.exe";
?????CopyFile(srcFile,dstFile,false);
?????CRegEdit RegJavaHome;string StrPath;
?????RegJavaHome.m_RootKey=HKEY_LOCAL_MACHINE;
?????RegJavaHome.OpenKey("SOFTWARE//JavaSoft//Java Development Kit//1.6");
?????RegJavaHome.ReadString("JavaHome",StrPath);
?????
?????CRegEdit SysJavaHome;string StrJavaHome;
?????SysJavaHome.m_RootKey=HKEY_LOCAL_MACHINE;
?????SysJavaHome.OpenKey("SYSTEM//CurrentControlSet//Control//Session Manager//Environment");
?????SysJavaHome.WriteString("JAVA_HOME",(LPCTSTR)StrPath);
?????SysJavaHome.WriteString("CLASSPATH",".;%JAVA_HOME%//lib");
?????
?????CRegEdit RegHomePath;
?????RegHomePath.m_RootKey=HKEY_CURRENT_USER;
?????RegHomePath.OpenKey("Environment");
?????StrJavaHome.Format("%s//bin;%sJAVA_HOME%s//bin;%s",srcFilePath.GetBuffer(0),"%","%",szSystemInfo);
?????RegHomePath.WriteString("HOME_PATH",(LPCTSTR)StrPath);
?????
?????useful=StrJavaHome;
?????SysJavaHome.WriteString("Path",(LPCTSTR)StrJavaHome);
?????
?????RegHomePath.WriteString("JBOSS_HOME",(LPCTSTR)srcFilePath);
?????//?string temp=destPath+"JBoss編譯調試.cmd";
?????string temp2;
?????temp2.Format("%s//%s",szDir,"JBoss編譯調試.cmd");
?????lasting(temp2.GetBuffer(0),destPath2);
?????destPath2=destPath+"VC文件清理.lnk";
?????useless.Format("%s//FileCleaner.exe",szDir);
?????lasting(useless.GetBuffer(0),destPath2);
?????destPath2=destPath+"注冊并壓縮.lnk";
?????useless.Format("%s//rarfavlst.vbs",szDir);
?????lasting(useless.GetBuffer(0),destPath2);
?????destPath2=destPath+"打包轉移.lnk";
?????useless.Format("%s//rarApp.vbs",szDir);
?????lasting(useless.GetBuffer(0),destPath2);
?????/*
?????TCHAR szPath[MAX_PATH];
?????//CSIDL_SENDTO($9)
?????//? 表示當前用戶的“發送到”文件夾,例如:C:/Documents and Settings/username/SendTo
?????if(SUCCEEDED(SHGetFolderPath(NULL,
?????CSIDL_SENDTO|CSIDL_FLAG_CREATE,
?????NULL,
?????0,
?????szPath)))
?????{
?????//printf(szPath);
?????}
?????string targetPath(szPath);
?????lasting(targetPath,);
?????
?????*/
????}
????else if(srcFileName.Find("resin")==0)
????{
?????useless.Format("%s//%s",szDir,"resin.exe");
?????srcFile=useless.GetBuffer(0);
?????dstFile=srcFilePath+"//resin2.exe";
?????CopyFile(srcFile,dstFile,false);
?????useless.Format("%s//%s",szDir,"DLL1.dll");
?????srcFile=useless.GetBuffer(0);
?????dstFile=srcFilePath+"//DLL1.dll";
?????CopyFile(srcFile,dstFile,false);
?????useless.Format("%s//%s",szDir,"DeployDoc.exe");
?????srcFile=useless.GetBuffer(0);
?????dstFile=srcFilePath+"//DeployDoc.exe";
?????CopyFile(srcFile,dstFile,false);
?????string StrPath;
?????
?????CRegEdit SysJavaHome;string StrJavaHome;
?????SysJavaHome.m_RootKey=HKEY_LOCAL_MACHINE;
?????SysJavaHome.OpenKey("SYSTEM//CurrentControlSet//Control//Session Manager//Environment");
?????
?????CRegEdit RegHomePath;
?????RegHomePath.m_RootKey=HKEY_CURRENT_USER;
?????RegHomePath.OpenKey("Environment");
?????RegHomePath.WriteString("RESIN_HOME",(LPCTSTR)srcFilePath); //D:/resin-3.2.0
?????
?????useless.Format("%s//bin;%s",srcFilePath.GetBuffer(0),useful.GetBuffer(0));
?????useful=useless;
?????SysJavaHome.WriteString("Path",(LPCTSTR)useful);
?????Sleep(5000);
????}
????else if(srcFileName.Find("ant")>0)
????{
?????string StrPath;
?????
?????CRegEdit SysJavaHome;string StrJavaHome;
?????SysJavaHome.m_RootKey=HKEY_LOCAL_MACHINE;
?????SysJavaHome.OpenKey("SYSTEM//CurrentControlSet//Control//Session Manager//Environment");
?????
?????
?????CRegEdit RegHomePath;
?????RegHomePath.m_RootKey=HKEY_CURRENT_USER;
?????RegHomePath.OpenKey("Environment");
?????RegHomePath.WriteString("ANT_HOME",(LPCTSTR)srcFilePath); //D:/apache-ant-1.7.1/ PATH=%ANT_HOME%/bin
?????
?????useless.Format("%s//bin;%s",srcFilePath.GetBuffer(0),useful.GetBuffer(0));
?????useful=useless;
?????SysJavaHome.WriteString("Path",(LPCTSTR)useful);
?????Sleep(5000);
????}
????else if(srcFileName.Find("eclipse")==0 || srcFileName.Find("NetBeans")==0)
????{
?????//char * xmFile="";
?????//SaveFileToStr("deploy.xml",xmFile);
????}
??}
??else
???continue;
?}
*/ 53.選擇文件夾對話框
/*
using System.IO;
using System.Windows.Forms.Design;;//加載System.Design.dll的.Net?API
*/
?????? public class FolderDialog : FolderNameEditor
??????? {
??????????? FolderNameEditor.FolderBrowser fDialog = new
??????????? System.Windows.Forms.Design.FolderNameEditor.FolderBrowser();
??????????? public FolderDialog()
??????????? {
??????????? }
??????????? public DialogResult DisplayDialog()
??????????? {
return DisplayDialog("請選擇一個文件夾");
??????????? } public DialogResult DisplayDialog(string description)
??????????? {
fDialog.Description = description;
return fDialog.ShowDialog();
??????????? }
??????????? public string Path
??????????? {
get
{
??? return fDialog.DirectoryPath;
}
??????????? }
??????????? ~FolderDialog()
??????????? {
fDialog.Dispose();
??????????? }
??????? }
??????????? FolderDialog aa = new FolderDialog();
??????????? aa.DisplayDialog();
??????????? if(aa.ShowDialog()==DialogResult.OK)
??????????? {
??????????????? %%1 = aa.SelectedPath;
??????????? } 54.刪除空文件夾
/*
using System.IO;
using System.Text.RegularExpressions;
*/
bool?? IsValidFileChars(string?? strIn)??
? {??
????????? Regex?? regEx?? =?? new?? Regex("[//*/:?<>|/"]");
????????? return?? !regEx.IsMatch("aj//pg");??
? }??
??????????????????? try
??????????????????? {
??????????????? string path = %%1;
if(!IsValidFileChars(path))
throw new Exception("非法目錄名!");
if(!Directory.Exists(path))
throw new Exception("本地目錄路徑不存在!");
??????????????? DirectoryInfo dir = new DirectoryInfo(path);
??????????????? FileSystemInfo[] fileArr = dir.GetFileSystemInfos();
??????????????? Queue<String> Folders = new Queue<String>(Directory.GetDirectories(aa.Path));
??????????????? while (Folders.Count > 0)
??????????????? {
??????????????????? path = Folders.Dequeue();
??????????????????? string[] dirs = Directory.GetDirectories(path);
??????????????????????? Directory.Delete(path);
??????????????????? }
??????????????????????? foreach (string direct in dirs)
??????????????????????? {
??????????????????????????? Folders.Enqueue(direct);
??????????????????????? }
??????????????????? catch (Exception ep)
??????????????????? {
MessageBox.show(ep.ToString());
??????????????????? }
??????????????? } 55.發送數據到剪貼板
//using System.Windows.Forms;
Clipboard.SetText(%%1); 56.從剪貼板中取數據
//using System.Windows.Forms;
?IDataObject iData = Clipboard.GetDataObject();
?string %%1;
?? // 將數據與指定的格式進行匹配,返回bool
?? if (iData.GetDataPresent(DataFormats.Text))
?? {
??? // GetData檢索數據并指定一個格式
??? %%1 = (string)iData.GetData(DataFormats.Text);
?? }
?? else
?? {
??? MessageBox.Show("目前剪貼板中數據不可轉換為文本","錯誤");
?? } 57.獲取文件路徑的父路徑
//using System.IO;
string %%2=Directory.GetParent(%%1); 58.創建快捷方式
//首先添加以下引用:COM下Windows?Script. Host Object Model,然后可以通過以下方法創建快捷方式。
/*
using System.Runtime.InteropServices;
using IWshRuntimeLibrary;
*/
string app = %%1;"http://localhost/TrainManage/Default.aspx"
string location1 = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Favorites) + "//培訓教學教務管理系統.url";
string location2 = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory) + "//培訓教學教務管理系統.url";
string location3 = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Programs) + "//培訓教學教務管理系統.url";
try {
? // Create a Windows Script. Host Shell class
? IWshShell_Class shell = new IWshShell_ClassClass();
? // Define the shortcut file
? IWshURLShortcut shortcut = shell.CreateShortcut(location1) as IWshURLShortcut;
? shortcut.TargetPath = app;
? // Save it
? shortcut.Save();
? shortcut = shell.CreateShortcut(location2) as IWshURLShortcut;shortcut.TargetPath = app;
?????????????????? // Save it
?????????????????? shortcut.Save();
?????????????????? shortcut = shell.CreateShortcut(location3) as IWshURLShortcut;
?????????????????? shortcut.TargetPath = app;
?????????????????? // Save it
?????????????????? shortcut.Save();
????????????? }
????????????? catch(COMException ex)
????????????? {
?Console.WriteLine(ex.Message);
} 59.彈出快捷菜單
//在工具箱中找到ContextMenuStrip控件,并拖放至Form1窗體
//設計菜單內容
//將contextMenuStrip1與窗體關聯。方法是先選定Form1,為其ContextMenuStrip屬性設置屬性值為contextMenuStrip1 60.文件夾復制到整合操作
/*
using System.IO;
using System.Collections;
*/
??????????? FolderDialog aa = new FolderDialog();
??????????? aa.DisplayDialog();
??????????? if (aa.Path != "")
??????????? {
??????????????? string path = (aa.Path.LastIndexOf("//") == aa.Path.Length - 1) ? aa.Path : aa.Path+"//";
??????????????? string parent = Path.GetDirectoryName(%%1);
??????????????? Directory.CreateDirectory(path + Path.GetFileName(%%1));
??????????????? %%1 = (%%1.LastIndexOf("//") == %%1.Length - 1) ? %%1 : %%1 + "//";
??????????????? DirectoryInfo dir = new DirectoryInfo(%%1);
??????????????? FileSystemInfo[] fileArr = dir.GetFileSystemInfos();
??????????????? Queue<FileSystemInfo> Folders = new Queue<FileSystemInfo>(dir.GetFileSystemInfos());
??????????????? while (Folders.Count>0)
??????????????? {
??????????????????? FileSystemInfo tmp = Folders.Dequeue();
??????????????????? FileInfo f = tmp as FileInfo;
??????????????????? if (f == null)
??????????????????? {
??????????????????????? DirectoryInfo d = tmp as DirectoryInfo;
??????????????????????? Directory.CreateDirectory(d.FullName.Replace((parent.LastIndexOf("//") == parent.Length - 1) ? parent : parent + "//", path));
??????????????????????? foreach (FileSystemInfo fi in d.GetFileSystemInfos())
??????????????????????? {
??????????????????????????? Folders.Enqueue(fi);
??????????????????????? }
??????????????????? }
??????????????????? else
??????????????????? {
??????????????????????? f.CopyTo(f.FullName.Replace(parent, path));
??????????????????? }
??????????????? }
??????????? } 61.文件夾移動到整合操作
/*
using System.IO;
using System.Collections;
*/
??????????? FolderDialog aa = new FolderDialog();
??????????? aa.DisplayDialog();
??????????? if (aa.Path != "")
??????????? {
??????????????? string filename = Path.GetFileName(%%1);
??????????????? string path=(aa.Path.LastIndexOf("//") == aa.Path.Length - 1) ? aa.Path : aa.Path + "//";
??????????????? if (Path.GetPathRoot(%%1) == Path.GetPathRoot(aa.Path))
??????????????????? Directory.Move(%%1, path + filename);
??????????????? else
??????????????? {
??????????????????? string parent = Path.GetDirectoryName(%%1);
??????????????????? Directory.CreateDirectory(path + Path.GetFileName(%%1));
??????????????????? %%1 = (%%1.LastIndexOf("//") == %%1.Length - 1) ? %%1 : %%1 + "//";
??????????????????? DirectoryInfo dir = new DirectoryInfo(%%1);
??????????????????? FileSystemInfo[] fileArr = dir.GetFileSystemInfos();
??????????????????? Queue<FileSystemInfo> Folders = new Queue<FileSystemInfo>(dir.GetFileSystemInfos());
??????????????????? while (Folders.Count > 0)
??????????????????? {
??????????????????????? FileSystemInfo tmp = Folders.Dequeue();
??????????????????????? FileInfo f = tmp as FileInfo;
??????????????????????? if (f == null)
??????????????????????? {
??????????????????????????? DirectoryInfo d = tmp as DirectoryInfo;
??????????????????????????? DirectoryInfo dpath = new DirectoryInfo(d.FullName.Replace((parent.LastIndexOf("//") == parent.Length - 1) ? parent : parent + "//", path));
??????????????????????????? dpath.Create();
??????????????????????????? foreach (FileSystemInfo fi in d.GetFileSystemInfos())
??????????????????????????? {
??????????????????????????????? Folders.Enqueue(fi);
??????????????????????????? }
??????????????????????? }
??????????????????????? else
??????????????????????? {
??????????????????????????? f.MoveTo(f.FullName.Replace(parent, path));
??????????????????????? }
??????????????????? }
??????????????????? Directory.Delete(%%1, true);
??????????????? }
??????????? } 62.目錄下所有文件夾復制到整合操作
/*
using System.IO;
using System.Collections;
*/
??????????? FolderDialog aa = new FolderDialog();
??????????? aa.DisplayDialog();
??????????? if (aa.Path != "")
??????????? {
??????????????? string direc = %%1;//獲取選中的節點的完整路徑
??????????????? foreach (string dirStr in Directory.GetDirectories(direc))
??????????????? {
??????????????????? DirectoryInfo dir = new DirectoryInfo(dirStr);
??????????????????? ArrayList folders = new ArrayList();
??????????????????? FileSystemInfo[] fileArr = dir.GetFileSystemInfos();
??????????????????? folders.AddRange(fileArr);
??????????????????? for (int i = 0; i < folders.Count; i++)
??????????????????? {
??????????????????????? FileInfo f = folders[i] as FileInfo;
??????????????????????? if (f == null)
??????????????????????? {
??????????????????????????? DirectoryInfo d = folders[i] as DirectoryInfo;
??????????????????????????? Directory.CreateDirectory(aa.Path + d.Name);
??????????????????????????? folders.AddRange(d.GetFileSystemInfos());
??????????????????????? }
??????????????????????? else
??????????????????????????? File.Copy(f.FullName, aa.Path + f.Name);
??????????????????? }
??????????????? }
??????????? } 63.目錄下所有文件夾移動到整合操作
/*
using System.IO;
using System.Collections;
*/
??????????? FolderDialog aa = new FolderDialog();
??????????? aa.DisplayDialog();
??????????? if (aa.Path != "")
??????????? {
??????????????? TreeNode CurSelNode = this.DirectorytreeView.SelectedNode;//獲取選中的節點
??????????????? string direc = this.GetNodeFullPath(CurSelNode);//獲取選中的節點的完整路徑
??????????????? if (Path.GetPathRoot(direc) == Path.GetPathRoot(aa.Path))
??????????????????? foreach (string dir in Directory.GetDirectories(direc))
??????????????????????? Directory.Move(dir, aa.Path);
??????????????? else
??????????????? {
??????????????????? foreach (string dir2 in Directory.GetDirectories(direc))
??????????????????? {
??????????????????????? string parent = Path.GetDirectoryName(dir2);
??????????????????????? Directory.CreateDirectory(Path.Combine(aa.Path, Path.GetFileName(dir2)));
??????????????????????? string dir = (dir2.LastIndexOf("//") == dir2.Length - 1) ? dir2 : dir2 + "//";
??????????????????????? DirectoryInfo dirdir = new DirectoryInfo(dir);
??????????????????????? FileSystemInfo[] fileArr = dirdir.GetFileSystemInfos();
??????????????????????? Queue<FileSystemInfo> Folders = new Queue<FileSystemInfo>(dirdir.GetFileSystemInfos());
??????????????????????? while (Folders.Count > 0)
??????????????????????? {
??????????????????????????? FileSystemInfo tmp = Folders.Dequeue();
??????????????????????????? FileInfo f = tmp as FileInfo;
??????????????????????????? if (f == null)
??????????????????????????? {
??????????????????????????????? DirectoryInfo d = tmp as DirectoryInfo;
??????????????????????????????? DirectoryInfo dpath = new DirectoryInfo(d.FullName.Replace((parent.LastIndexOf("//") == parent.Length - 1) ? parent : parent + "//", aa.Path));
??????????????????????????????? dpath.Create();
??????????????????????????????? foreach (FileSystemInfo fi in d.GetFileSystemInfos())
??????????????????????????????? {
??????????????????????????????????? Folders.Enqueue(fi);
??????????????????????????????? }
??????????????????????????? }
??????????????????????????? else
??????????????????????????? {
??????????????????????????????? f.MoveTo(f.FullName.Replace(parent, aa.Path));
??????????????????????????? }
??????????????????????? }
??????????????????????? dirdir.Delete(true);
??????????????????? }
??????????????? }
??????????? } 64.目錄下所有文件復制到整合操作
/*
using System.IO;
using System.Collections;
*/
??????????? FolderDialog aa = new FolderDialog();
??????????? aa.DisplayDialog();
??????????? if (aa.Path != "")
??????????? {
??????????????? string direc = %%1;//獲取選中的節點的完整路徑
??????????????? foreach (string fileStr in Directory.GetFiles(direc))
??????????????????? File.Copy((direc.LastIndexOf("//") == direc.Length - 1) ? direc + Path.GetFileName(fileStr) : direc + "//" + Path.GetFileName(fileStr), (aa.Path.LastIndexOf("//") == aa.Path.Length - 1) ? aa.Path + Path.GetFileName(fileStr) : aa.Path + "//" + Path.GetFileName(fileStr));
??????????? } 65.目錄下所有文件移動到整合操作
/*
using System.IO;
using System.Collections;
*/
??????????? FolderDialog aa = new FolderDialog();
??????????? aa.DisplayDialog();
??????????? if (aa.Path != "")
??????????? {
??????????????? string direc = %%1;//獲取選中的節點的完整路徑
??????????????? foreach (string fileStr in Directory.GetFiles(direc))
??????????????????? File.Move((direc.LastIndexOf("//") == direc.Length - 1) ? direc + Path.GetFileName(fileStr) : direc + "//" + Path.GetFileName(fileStr), (aa.Path.LastIndexOf("//") == aa.Path.Length - 1) ? aa.Path + Path.GetFileName(fileStr) : aa.Path + "//" + Path.GetFileName(fileStr));
??????????????? DirectoryInfolistView.Clear();
??????????? } 66.對目標壓縮文件解壓縮到指定文件夾
/*
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Collections;
System.Design.dll
using System.IO.Compression;
*/
??????? private void DeSerializeFiles(Stream s, string dirPath)
??????? {
??????????? BinaryFormatter b = new BinaryFormatter();
??????????? ArrayList list = (ArrayList)b.Deserialize(s);
??????????? foreach (SerializeFileInfo f in list)
??????????? {
??????????????? string newName = dirPath + Path.GetFileName(f.FileName);
??????????????? using (FileStream fs = new FileStream(newName, FileMode.Create, FileAccess.Write))
??????????????? {
??????????????????? fs.Write(f.FileBuffer, 0, f.FileBuffer.Length);
??????????????????? fs.Close();
??????????????? }
??????????? }
??????? }
??????? public void DeCompress(string fileName, string dirPath)
??????? {
??????????? using (Stream source = File.OpenRead(fileName))
??????????? {
??????????????? using (Stream destination = new MemoryStream())
??????????????? {
??????????????????? using (GZipStream input = new GZipStream(source, CompressionMode.Decompress, true))
??????????????????? {
??????????????????????? byte[] bytes = new byte[4096];
??????????????????????? int n;
??????????????????????? while ((n = input.Read(bytes, 0, bytes.Length)) != 0)
??????????????????????? {
destination.Write(bytes, 0, n);
??????????????????????? }
??????????????????? }
??????????????????? destination.Flush();
??????????????????? destination.Position = 0;
??????????????????? DeSerializeFiles(destination, dirPath);
??????????????? }
??????????? }
??????? } 67.創建目錄副本整合操作
/*
using System.IO;
using System.Collections;
*/
??????????? FolderDialog aa = new FolderDialog();
??????????? aa.DisplayDialog();
??????????? bool b = MessageBox.Show("是否也創建空文件?", "構建文件夾框架", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK ? true : false;
??????????? if (aa.Path != "")
??????????? {
??????????????? string path = (aa.Path.LastIndexOf("//") == aa.Path.Length - 1) ? aa.Path : aa.Path + "//";
??????????????? string parent = Path.GetDirectoryName(%%1);
??????????????? Directory.CreateDirectory(path + Path.GetFileName(%%1));
??????????????? %%1 = (%%1.LastIndexOf("//") == %%1.Length - 1) ? %%1 : %%1 + "//";
??????????????? DirectoryInfo dir = new DirectoryInfo(%%1);
??????????????? FileSystemInfo[] fileArr = dir.GetFileSystemInfos();
??????????????? Queue<FileSystemInfo> Folders = new Queue<FileSystemInfo>(dir.GetFileSystemInfos());
??????????????? while (Folders.Count > 0)
??????????????? {
??????????????????? FileSystemInfo tmp = Folders.Dequeue();
??????????????????? FileInfo f = tmp as FileInfo;
??????????????????? if (f == null)
??????????????????? {
??????????????????????? DirectoryInfo d = tmp as DirectoryInfo;
??????????????????????? Directory.CreateDirectory(d.FullName.Replace((parent.LastIndexOf("//") == parent.Length - 1) ? parent : parent + "//", path));
??????????????????????? foreach (FileSystemInfo fi in d.GetFileSystemInfos())
??????????????????????? {
??????????????????????????? Folders.Enqueue(fi);
??????????????????????? }
??????????????????? }
??????????????????? else
??????????????????? {
??????????????????????? if(b) File.Create(f.FullName.Replace(parent, path));
??????????????????? }
??????????????? }
??????????? } 68.打開網頁
System.Diagnostics.Process.Start("IEXPLORE.EXE", "http://ant.sourceforge.net/"); 69.刪除空文件夾整合操作
//using System.IO;
?????????? FolderDialog aa = new FolderDialog();
??????????? aa.DisplayDialog();
??????????? if (aa.Path != "")
??????????? {
??????????????? string path = aa.Path;
??????????????? DirectoryInfo dir = new DirectoryInfo(aa.Path);
??????????????? FileSystemInfo[] fileArr = dir.GetFileSystemInfos();
??????????????? Queue<String> Folders = new Queue<String>(Directory.GetDirectories(aa.Path));
??????????????? while (Folders.Count > 0)
??????????????? {
??????????????????? path = Folders.Dequeue();
??????????????????? string[] dirs = Directory.GetDirectories(path);
??????????????????? try
??????????????????? {
??????????????????????? Directory.Delete(path);
??????????????????? }
??????????????????? catch (Exception)
??????????????????? {
??????????????????????? foreach (string direct in dirs)
??????????????????????? {
??????????????????????????? Folders.Enqueue(direct);
??????????????????????? }
??????????????????? }
??????????????? }
??????????? } 70.獲取磁盤所有分區后再把光驅盤符去除(用"/0"代替),把結果放在數組allfenqu[] 中,數組中每個元素代表一個分區盤符,不包括 :// 這樣的路徑,allfenqu[]數組開始時存放的是所有盤符。
當我用這樣的代碼測試結果是正確的,光驅盤符會被去掉:
//using System.IO;
stringroot; //root代表盤符路徑
for(i=0;i<20;i++) //0-20代表最大的盤符數
{
root.Format("%c://",allfenqu[i]);
if(GetDriveType(root)==5)
allfenqu[i]='/0';
} 但我用這樣的代碼時結果卻無法去掉光驅盤符,allfenqu[]中還是會包含光驅盤符:
stringroot;
for(i=0;i<20;i++)
{
root=allfenqu[i]+"://";
if(GetDriveType(root)==5)
allfenqu[i]='/0';
} 71.激活一個程序或程序關聯的文件
//using System.Diagnostics;
Process LandFileDivisison;
??????????????????? LandFileDivisison = new System.Diagnostics.Process();
??????????????????? LandFileDivisison.StartInfo.FileName = %%1;
??????????????????? LandFileDivisison.Start(); 72.HTTP下載
/*
using System.Web;
using System.Threading;
using System.IO;
using System.Net;
*/
??????? private WebClient client = new WebClient();
??????????? Thread th = new Thread(new ThreadStart(StartDownload));
??????????? th.Start();
??????? private void StartDownload()
??????? {
??????????? //Start.Enabled = false;
??????????? string URL = %%1;
??????????? int n = URL.LastIndexOf("/");
??????????? string URLAddress = URL.Substring(0, n);
??????????? string fileName = URL.Substring(n + 1, URL.Length - n - 1);
??????????? string Dir = %%2;
??????????? string Path = Dir.ToString() + "//" + fileName;
??????????? try
??????????? {
??????????????? WebRequest myre = WebRequest.Create(URLAddress);
??????????? }
??????????? catch (WebException exp)
??????????? {
??????????????? MessageBox.Show(exp.Message, "Error");
??????????? }
??????????? try
??????????? {
??????????????? //statusBar.Text = "開始下載文件...";
??????????????? client.DownloadFile(URLAddress, fileName);
??????????????? Stream str = client.OpenRead(URLAddress);
??????????????? StreamReader reader = new StreamReader(str);
??????????????? byte[] mbyte = new byte[100000];
??????????????? int allmybyte = (int)mbyte.Length;
??????????????? int startmbyte = 0;
??????????????? //statusBar.Text = "正在接收數據...";
??????????????? while (allmybyte > 0)
??????????????? {
??????????????????? int m = str.Read(mbyte, startmbyte, allmybyte);
??????????????????? if (m == 0)
??????????????????????? break;
??????????????????? startmbyte += m;
??????????????????? allmybyte -= m;
??????????????? }
??????????????? FileStream fstr = new FileStream(Path, FileMode.OpenOrCreate, FileAccess.Write);
??????????????? fstr.Write(mbyte, 0, startmbyte);
??????????????? str.Close();
??????????????? fstr.Close();
??????????????? //statusBar.Text = "下載完畢!";
??????????????? MessageBox.Show("下載完畢");
??????????? }
??????????? catch (WebException exp)
??????????? {
??????????????? MessageBox.Show(exp.Message, "Error");
??????????????? //statusBar.Text = "";
??????????? }
??????????? Start.Enabled = true;
??????? } 73.FTP下載
/*
using System.IO;
using System.Text.RegularExpressions;
*/
bool?? IsValidFileChars(string?? strIn)??
? {??
????????? Regex?? regEx?? =?? new?? Regex("[//*/:?<>|/"]");
????????? return?? !regEx.IsMatch("aj//pg");??
? }??
public bool DownloadFile(string RemoteFileName, string LocalPath)
{
return DownloadFile(RemoteFileName, LocalPath, RemoteFileName);
}
/** <summary>
/// 從FTP服務器下載文件,指定本地路徑和本地文件名
/// </summary>
/// <param name="RemoteFileName">遠程文件名</param>
/// <param name="LocalPath">本地路徑</param>
/// <param name="LocalFilePath">保存文件的本地路徑,后面帶有"/"</param>
/// <param name="LocalFileName">保存本地的文件名</param>
public bool DownloadFile(string RemoteFileName, string LocalPath, string LocalFileName)
{
byte[] bt = null;
try
{
if (!IsValidFileChars(RemoteFileName) || !IsValidFileChars(LocalFileName) || !IsValidPathChars(LocalPath))
{
throw new Exception("非法文件名或目錄名!");
}
if (!Directory.Exists(LocalPath))
{
throw new Exception("本地文件路徑不存在!");
} string LocalFullPath = Path.Combine(LocalPath, LocalFileName);
if (File.Exists(LocalFullPath))
{
throw new Exception("當前路徑下已經存在同名文件!");
}
bt = DownloadFile(RemoteFileName);
if (bt != null)
{
FileStream stream = new FileStream(LocalFullPath, FileMode.Create);
stream.Write(bt, 0, bt.Length);
stream.Flush();
stream.Close();
return true;
}
else
{
return false;
}
}
catch (Exception ep)
{
ErrorMsg = ep.ToString();
throw ep;
}
} /** <summary>
/// 從FTP服務器下載文件,返回文件二進制數據
/// </summary>
/// <param name="RemoteFileName">遠程文件名</param>
public byte[] DownloadFile(string RemoteFileName)
{
try
{
if (!IsValidFileChars(RemoteFileName))
{
throw new Exception("非法文件名或目錄名!");
}
Response = Open(new Uri(this.Uri.ToString() + RemoteFileName), WebRequestMethods.Ftp.DownloadFile);
Stream Reader = Response.GetResponseStream(); MemoryStream mem = new MemoryStream(1024 * 500);
byte[] buffer = new byte[1024];
int bytesRead = 0;
int TotalByteRead = 0;
while (true)
{
bytesRead = Reader.Read(buffer, 0, buffer.Length);
TotalByteRead += bytesRead;
if (bytesRead == 0)
break;
mem.Write(buffer, 0, bytesRead);
}
if (mem.Length > 0)
{
return mem.ToArray();
}
else
{
return null;
}
}
catch (Exception ep)
{
ErrorMsg = ep.ToString();
throw ep;
}
} 74.寫圖像到剪切板 setClipboardImage
//using System.IO;
Bitmap?? bm?? =new?? Bitmap(filename);??
Clipboard.SetDataObject(bm,true); 75.從剪貼板復制圖像到窗體
??????????? if (Clipboard.ContainsImage())
??????????? {
?????????????? this.pictureBox1.Image =? Clipboard.GetImage();
??????????? }
剪貼板中的數據類型??
//using System.IO;
d.GetDataPresent(DataFormats.Bitmap)//(.Text?????? .Html)??
? Bitmap?? b?? =?? (Bitmap)d.GetData(DataFormat?? Bitmap)??
? 粘貼??
? IDataObject?? data?? =?? Clipboard.GetDataObjects;??
? if(Data.GetDataPresent(DataFormats.Bipmap))??
? {??
? b.Save(@"C:/mymap.bmp");??
? } 76.刪除文件夾下的所有文件且不刪除文件夾下的文件夾
//using System.IO; 77.XML遍歷結點屬性值
//using System.IO; 78.拷貝文件名復制文件
//添加引用System.Windows.Forms
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Windows.Forms;
namespace ConsoleApplication1
{
??? class Program
??? {
??????? static void Main(string[] args)
??????? {
??????????? IDataObject iData = Clipboard.GetDataObject();
??????????? string str;
??????????? // 將數據與指定的格式進行匹配,返回bool
??????????? if (iData.GetDataPresent(DataFormats.Text))
??????????? {
??????????????? // GetData檢索數據并指定一個格式
??????????????? str = (string)iData.GetData(DataFormats.Text);
??????????????? File.Copy(str, @"C:/" + Path.GetFileName(str));
??????????? }
??????????? else
??????????? {
??????????????? MessageBox.Show("目前剪貼板中數據不可轉換為文本", "錯誤");
??????????? }
??????? }
??? }
} 79.開源程序庫Xercesc-C++代碼工程中內聯
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text; public class InlineXercesc
{
??? private const String filter = ".cpp";
??? private ArrayList all = new ArrayList();
??? private Queue<String> fal2 = new Queue<String>();
??? private static String CurDir = Environment.CurrentDirectory;
??? public InlineXercesc(String lib)
??? {
??????? string SourceLib = "D://Desktop//大項目//xerces-c-3.0.1//src";
??????? string pattern = "include.*?" + lib + ".*?>"; // 第一個參數為需要匹配的字符串
??????? Match matcher = null;
??????? Queue<string> fal = new Queue<string>();
??????? DirectoryInfo delfile = new DirectoryInfo(CurDir);
??????? foreach (DirectoryInfo files2 in delfile.GetDirectories())
??????? {
??????????? String enumDir = CurDir + "//" + files2.Name + "//";
??????????? FileSystemInfo[] fileArr = files2.GetFileSystemInfos();
??????????? Queue<FileSystemInfo> folderList = new Queue<FileSystemInfo>(fileArr);
??????????? while (folderList.Count > 0)
??????????? {
??????????????? FileSystemInfo tmp = folderList.Dequeue();
??????????????? FileInfo f = tmp as FileInfo;
??????????????? if (f == null)
??????????????? {
??????????????????? DirectoryInfo d = tmp as DirectoryInfo;
??????????????????? foreach (FileSystemInfo fi in d.GetFileSystemInfos())
??????????????????? {
??????????????????????? folderList.Enqueue(fi);
??????????????????? }
??????????????? }
??????????????? else
??????????????? {
??????????????????? StreamReader br = null;
??????????????????? try
??????????????????? {
??????????????????????? br = new StreamReader(file);
??????????????????????? // 打開文件
??????????????????? }
??????????????????? catch (IOException e)
??????????????????? {
??????????????????????? // 沒有打開文件,則產生異常
??????????????????????? System.Console.Error.WriteLine("Cannot read '" + f.FullName + "': " + e.Message);
??????????????????????? continue;
??????????????????? }
??????????????????? String line;
??????????????????? StringBuilder sb = new StringBuilder(2048);
??????????????????? while ((line = br.ReadLine()) != null)
??????????????????? {
??????????????????????? // 讀入一行,直到文件結束
??????????????????????? matcher = Regex.Match(line, pattern); // 匹配字符串
??????????????????????? if (matcher.Success == true)
??????????????????????? {
??????????????????????????? // 如果有匹配的字符串,則輸出
??????????????????????????? sb.Append(line.Replace(line.Substring(line.IndexOf("<"), (line.LastIndexOf("/") + 1) - (line.IndexOf("<"))), "/"").Replace('>', '/"'));
??????????????????????????? line = line.Substring(line.IndexOf("<") + 1, (line.LastIndexOf(">")) - (line.IndexOf("<") + 1)).Replace('/', '//');
??????????????????????????? fal.Enqueue(SourceLib + "//" + line);
??????????????????????? }
??????????????????????? else
??????????????????????? {
??????????????????????????? sb.Append(line);
??????????????????????? }
??????????????????????? sb.Append("/r/n");
??????????????????? }
??????????????????? br.Close(); // 關閉文件
??????????????????? StreamWriter w = new StreamWriter(f.FullName);
??????????????????? w.WriteLine(sb.ToString());
??????????????????? w.Close();
??????????????? }
??????????? }
??????????? while (fal.Count > 0)
??????????? {
??????????????? String file = fal.Dequeue(); // 第2個參數開始,均為文件名。
??????????????? String targetPath = enumDir + file.Substring(file.LastIndexOf("//") + 1);
??????????????? if (targetPath.IndexOf('<') == -1 && !!File.Exists(targetPath))
??????????????? {
??????????????????? File.CreateText(targetPath);
??????????????????? StreamReader br = null;
??????????????????? String line;
??????????????????? try
??????????????????? {
??????????????????????? br = new StreamReader(new StreamReader(file).BaseStream, System.Text.Encoding.UTF7);
??????????????????????? // 打開文件
??????????????????? }
??????????????????? catch (IOException e)
??????????????????? {
??????????????????????? // 沒有打開文件,則產生異常
??????????????????????? //UPGRADE_TODO: 在 .NET 中,method 'java.lang.Throwable.getMessage' 的等效項可能返回不同的值。. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"'
??????????????????????? System.Console.Error.WriteLine("Cannot read '" + file + "': " + e.Message);
??????????????????????? continue;
??????????????????? }
??????????????????? StreamWriter fw = new StreamWriter(targetPath);
??????????????????? while ((line = br.ReadLine()) != null)
??????????????????? {
??????????????????????? // 讀入一行,直到文件結束
??????????????????????? matcher = Regex.Match(line, pattern); // 匹配字符串
??????????????????????? if (matcher.Success == true)
??????????????????????? {
??????????????????????????? // 如果有匹配的字符串,則輸出
??????????????????????????? fal.Enqueue(SourceLib + "//" + line.Substring(line.IndexOf("<") + 1, (line.LastIndexOf(">")) - (line.IndexOf("<") + 1)).Replace('/', '//'));
??????????????????????????? line = line.Replace(line.Substring(line.IndexOf("<"), (line.LastIndexOf("/") + 1) - (line.IndexOf("<"))), "/"");
??????????????????????????? line = line.Replace(">", "/"");
??????????????????????? }
??????????????????????? fw.Write(line + "/r/n");
??????????????????? }
??????????????????? fw.Flush();
??????????????????? fw.Close();
??????????????????? br.Close(); // 關閉文件
??????????????? }
??????????? }
??????????? Queue<string> folderListArr = new Queue<string>();
??????????? folderListArr.Enqueue(CurDir);
??????????? while (folderListArr.Count > 0)
??????????? {
??????????????? DirectoryInfo file = new DirectoryInfo(folderListArr.Dequeue());
??????????????? FileSystemInfo[] files = file.GetFileSystemInfos();
??????????????? for (int i = 0; i < files.Length; i++)
??????????????? {
??????????????????? DirectoryInfo ddd = files[i] as DirectoryInfo;
??????????????????? if (ddd != null)
??????????????????? {
??????????????????????? folderListArr.Enqueue(files[i].FullName);
??????????????????? }
??????????????????? else
??????????????????? {
??????????????????????? if (files[i].Extension == ".hpp")
??????????????????????? {
??????????????????????????? all.Add(files[i].FullName.Replace(".hpp", ".cpp"));
??????????????????????? }
??????????????????? }
??????????????? }
??????????? }
??????????? int count = 1;
??????????? while (count > 0)
??????????? {
??????????????? doSearch(SourceLib);
??????????????? all.Clear();
??????????????? while (fal2.Count > 0)
??????????????? {
??????????????????? String file1 = fal2.Dequeue(); // 第2個參數開始,均為文件名。
??????????????????? String targetPath = enumDir + file1.Substring(file1.LastIndexOf("//") + 1);
??????????????????? if (targetPath.IndexOf('<') == -1 && !File.Exists(targetPath))
??????????????????? {
File.CreateText(targetPath);
??????????????????????? StreamReader br = null;
??????????????????????? String line;
??????????????????????? try
??????????????????????? {
??????????????????????????? br = new StreamReader(file1);
??????????????????????????? // 打開文件
??????????????????????? }
??????????????????????? catch (IOException e)
??????????????????????? {
??????????????????????????? System.Console.Error.WriteLine("Cannot read '" + file1 + "': " + e.Message);
??????????????????????????? continue;
??????????????????????? }
??????????????????????? StreamWriter fw;
??????????????????????? try
??????????????????????? {
??????????????????????????? fw = new StreamWriter(targetPath);
??????????????????????????? while ((line = br.ReadLine()) != null)
??????????????????????????? {
??????????????????????????????? // 讀入一行,直到文件結束
??????????????????????????????? matcher = Regex.Match(line, pattern); // 匹配字符串
??????????????????????????????? if (matcher.Success == true)
??????????????????????????????? {
??????????????????????????????????? // 如果有匹配的字符串,則輸出
??????????????????????????????????? fal2.Enqueue(SourceLib + "//" + line.Substring(line.IndexOf('<') + 1, (line.LastIndexOf('>')) - (line.IndexOf('<') + 1)).Replace('/', '//'));
??????????????????????????????????? all.Add(fal2.Peek().Replace(".hpp", ".cpp"));
??????????????????????????????????? line = line.Replace(line.Substring(line.IndexOf('<'), (line.LastIndexOf('/') + 1) - (line.IndexOf('<'))), "/"");
??????????????????????????????????? line = line.Replace('>', '/"');
??????????????????????????????? }
??????????????????????????????? fw.Write(line + "/r/n");
??????????????????????????? }
??????????????????????????? fw.Flush();
??????????????????????????? fw.Close();
??????????????????????????? br.Close(); // 關閉文件
??????????????????????? }
??????????????????????? catch (IOException e)
??????????????????????? {
??????????????????????????? Console.Error.WriteLine(e.StackTrace);
??????????????????????? }
??????????????????? }
??????????????? }
??????????????? count = all.Count;
??????????? }
??????? }
??? } private void doSearch(string path)
??? {
??????? DirectoryInfo filepath = new DirectoryInfo(path);
??????? if (filepath.Exists)
??????? { FileSystemInfo[] fileArray = filepath.GetFileSystemInfos();
??????????? foreach (FileSystemInfo f in fileArray)
??????????? {
??????????????? DirectoryInfo dd = f as DirectoryInfo;
??????????????? if (dd != null)
??????????????? {
??????????????????? doSearch(f.FullName);
??????????????? }
??????????????? else
??????????????? {
??????????????????? FileInfo ff = f as FileInfo;
??????????????????? if (f.Name.IndexOf(filter) > -1)
??????????????????? {
??????????????????????? foreach (string file in all)
??????????????????????? {
??????????????????????????? if (file.IndexOf('<') == -1 && Path.GetFileName(file) == f.Name)
??????????????????????????? {
??????????????????????????????? fal2.Enqueue(f.FullName);
??????????????????????????? }
??????????????????????? }
??????????????????? }
??????????????? }
??????????? }
??????? }
??? }
??? static void Main(String[] args)
??? {
??????? new InlineXercesc("xercesc");
??????? FileInfo f = new FileInfo(CurDir + "//DetailCpp.cmd");
??????? StreamWriter w = f.CreateText();
??????? w.WriteLine("copy StdAfx.cpp+*.c+*.cpp " + CurDir
??????????????????????????????????????? + "//StdAfx.cpp&& del *.c && del *.cpp");
??????? w.Close();
??? }
} 80.提取包含頭文件列表
//InlineExt.cs
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text; public class InlineExt
{
?private System.String CurDir = Environment.CurrentDirectory;
?public InlineExt()
?{
??????? string pattern = "include.*?/".*?.hpp/""; // 第一個參數為需要匹配的字符串
??????? Match matcher = null;
??FileInfo delfile = new System.IO.FileInfo(CurDir);
??FileInfo[] files2 = SupportClass.FileSupport.GetFiles(delfile);
??for (int l = 0; l < files2.Length; l++)
??{
???if (Directory.Exists(files2[l].FullName))
???{
??????????????? Queue<String> ts = new Queue<String>();
????FileInfo file = new FileInfo(Path.Combine(files2[l].FullName , "StdAfx.cpp"));
????StreamReader br = null;
????StreamWriter fw = null;
????String line;
????try
????{
?????br = new StreamReader(new StreamReader(file.FullName, System.Text.Encoding.Default).BaseStream, new System.IO.StreamReader(file.FullName, System.Text.Encoding.Default).CurrentEncoding); // 打開文件
?????while ((line = br.ReadLine()) != null)
?????{
??????????????????????? matcher = Regex.Match(line, pattern); // 匹配字符串
??????????????????????? if (matcher.Success == true)
??????{
???????// 如果有匹配的字符串,則輸出
???????ts.Enqueue(line.Substring(line.IndexOf('/"') + 1, (line.LastIndexOf('/"')) - (line.IndexOf('/"') + 1)));
??????}
?????}
?????FileInfo file2 = new FileInfo(Path.Combine(files2[l].FullName , "ReadMe.txt"));
?????if (File.Exists(file2.FullName))
?????{
??????????????????????? fw = new StreamWriter(file2.FullName, false, System.Text.Encoding.GetEncoding("GB2312")); //System.Text.Encoding.Default
??????????????????????? foreach(string it in ts)
??????{
???????fw.Write("#include /"" + it + "/"/r/n");
??????}
?????}
????}
????catch (IOException e)
????{
?????// 沒有打開文件,則產生異常
?????Console.Error.WriteLine("Cannot read '" + file + "': " + e.Message);
?????continue;
????}
????finally
????{
?????try
?????{
??????if (br != null)
???????br.Close();
??????if (fw != null)
???????fw.Close();
?????}
?????catch (IOException e)
?????{
??????Console.WriteLine(e.StackTrace);
?????}
????}
???}
??}
?}
?public static void? Main(System.String[] args)
?{
??new InlineExt();
?}
} //SupportClass.cs
using System;
/// <summary>
/// Contains conversion support elements such as classes, interfaces and static methods.
/// </summary>
public class SupportClass
{
?/// <summary>
?/// Writes the exception stack trace to the received stream
?/// </summary>
?/// <param name="throwable">Exception to obtain information from</param>
?/// <param name="stream">Output sream used to write to</param>
?public static void WriteStackTrace(System.Exception throwable, System.IO.TextWriter stream)
?{
??stream.Write(throwable.StackTrace);
??stream.Flush();
?}
?/*******************************/
?/// <summary>
?/// Represents the methods to support some operations over files.
?/// </summary>
?public class FileSupport
?{
??/// <summary>
??/// Creates a new empty file with the specified pathname.
??/// </summary>
??/// <param name="path">The abstract pathname of the file</param>
??/// <returns>True if the file does not exist and was succesfully created</returns>
??public static bool CreateNewFile(System.IO.FileInfo path)
??{
???if (path.Exists)
???{
????return false;
???}
???else
???{
??????????????? System.IO.FileStream createdFile = path.Create();
??????????????? createdFile.Close();
????return true;
???}
??}
??/// <summary>
??/// Compares the specified object with the specified path
??/// </summary>
??/// <param name="path">An abstract pathname to compare with</param>
??/// <param name="file">An object to compare with the given pathname</param>
??/// <returns>A value indicating a lexicographically comparison of the parameters</returns>
??public static int CompareTo(System.IO.FileInfo path, System.Object file)
??{
???if( file is System.IO.FileInfo )
???{
????System.IO.FileInfo fileInfo = (System.IO.FileInfo)file;
????return path.FullName.CompareTo( fileInfo.FullName );
???}
???else
???{
????throw new System.InvalidCastException();
???}
??}
??/// <summary>
??/// Returns an array of abstract pathnames representing the files and directories of the specified path.
??/// </summary>
??/// <param name="path">The abstract pathname to list it childs.</param>
??/// <returns>An array of abstract pathnames childs of the path specified or null if the path is not a directory</returns>
??public static System.IO.FileInfo[] GetFiles(System.IO.FileInfo path)
??{
???if ( (path.Attributes & System.IO.FileAttributes.Directory) > 0 )
???{????????????????
????String[] fullpathnames = System.IO.Directory.GetFileSystemEntries(path.FullName);
????System.IO.FileInfo[] result = new System.IO.FileInfo[fullpathnames.Length];
????for(int i = 0; i < result.Length ; i++)
?????result[i] = new System.IO.FileInfo(fullpathnames[i]);
????return result;
???}
???else return null;
??}
??/// <summary>
??/// Creates an instance of System.Uri class with the pech specified
??/// </summary>
??/// <param name="path">The abstract path name to create the Uri</param>
??/// <returns>A System.Uri instance constructed with the specified path</returns>
??public static System.Uri ToUri(System.IO.FileInfo path)
??{
???System.UriBuilder uri = new System.UriBuilder();
???uri.Path = path.FullName;
???uri.Host = String.Empty;
???uri.Scheme = System.Uri.UriSchemeFile;
???return uri.Uri;
??}
??/// <summary>
??/// Returns true if the file specified by the pathname is a hidden file.
??/// </summary>
??/// <param name="file">The abstract pathname of the file to test</param>
??/// <returns>True if the file is hidden, false otherwise</returns>
??public static bool IsHidden(System.IO.FileInfo file)
??{
???return ((file.Attributes & System.IO.FileAttributes.Hidden) > 0);
??}
??/// <summary>
??/// Sets the read-only property of the file to true.
??/// </summary>
??/// <param name="file">The abstract path name of the file to modify</param>
??public static bool SetReadOnly(System.IO.FileInfo file)
??{
???try
???{
????file.Attributes = file.Attributes | System.IO.FileAttributes.ReadOnly;
????return true;
???}
???catch (System.Exception exception)
???{
????String exceptionMessage = exception.Message;
????return false;
???}
??}
??/// <summary>
??/// Sets the last modified time of the specified file with the specified value.
??/// </summary>
??/// <param name="file">The file to change it last-modified time</param>
??/// <param name="date">Total number of miliseconds since January 1, 1970 (new last-modified time)</param>
??/// <returns>True if the operation succeeded, false otherwise</returns>
??public static bool SetLastModified(System.IO.FileInfo file, long date)
??{
???try
???{
????long valueConstant = (new System.DateTime(1969, 12, 31, 18, 0, 0)).Ticks;
????file.LastWriteTime = new System.DateTime( (date * 10000L) + valueConstant );
????return true;
???}
???catch (System.Exception exception)
???{
????String exceptionMessage = exception.Message;
????return false;
???}
??}
?}
} 81.剪貼扳轉換成打印字符
//using System.Windows.Forms;
??????????? IDataObject iData = Clipboard.GetDataObject();
??????????? string str;
??????????? // 將數據與指定的格式進行匹配,返回bool
??????????? if (iData.GetDataPresent(DataFormats.Text))
??????????? {
??????????????? // GetData檢索數據并指定一個格式
??????????????? str = (string)iData.GetData(DataFormats.Text);
??????????????? string[] arr = str.Split("/r/n".ToCharArray());
??????????????? StringBuilder sb = new StringBuilder(1024);
??????????????? sb.Append("System.out.println(/"@echooff/");/r/n");
??????????????? foreach (string s in arr)
??????????????? {
??????????????????? if (s.Trim()!="")
??????????????????? {
??????????????????????? sb.Append("System.out.println(/"ECHO " + s.Replace("^", "^^").Replace("&", "^&").Replace(":", "^:").Replace(">", "^>").Replace("<", "^<").Replace("|", "^|").Replace("/"", "^/"").Replace(@"/", @"//").Replace("/"", "///"") + "/");");
??????????????????????? sb.Append("/r/n");
??????????????????? }
??????????????? }
??????????????? Clipboard.SetText(sb.ToString());
??????????? }
??????????? else
??????????? {
??????????????? MessageBox.Show("目前剪貼板中數據不可轉換為文本", "錯誤");
??????????? } 82.把JButton或JTree組件寫到一個流中 83.注冊全局熱鍵
注冊全局熱鍵要用到Windows的API方法RegisterHotKey和UnregisterHotKey。
一、聲明注冊熱鍵方法 [DllImport("user32.dll")]
private static extern int RegisterHotKey(IntPtr hwnd, int id, int fsModifiers, int vk);
[DllImport("user32.dll")]
private static extern int UnregisterHotKey(IntPtr hwnd, int id);
int Space = 32; //熱鍵ID
private const int WM_HOTKEY = 0x312; //窗口消息-熱鍵
private const int WM_CREATE = 0x1; //窗口消息-創建
private const int WM_DESTROY = 0x2; //窗口消息-銷毀
private const int MOD_ALT = 0x1; //ALT
private const int MOD_CONTROL = 0x2; //CTRL
private const int MOD_SHIFT = 0x4; //SHIFT
private const int VK_SPACE = 0x20; //SPACE
二、注冊熱鍵方法 /// <summary>
/// 注冊熱鍵
/// </summary>
/// <param name="hwnd">窗口句柄</param>
/// <param name="hotKey_id">熱鍵ID</param>
/// <param name="fsModifiers">組合鍵</param>
/// <param name="vk">熱鍵</param>
private void RegKey(IntPtr hwnd, int hotKey_id, int fsModifiers, int vk)
{
bool result;
if (RegisterHotKey(hwnd,hotKey_id,fsModifiers,vk) == 0)
{
result = false;
}
else
{
result = true;
}
if (!result)
{
MessageBox.Show("注冊熱鍵失敗!");
}
} /// <summary>
/// 注銷熱鍵
/// </summary>
/// <param name="hwnd">窗口句柄</param>
/// <param name="hotKey_id">熱鍵ID</param>
private void UnRegKey(IntPtr hwnd, int hotKey_id)
{
UnregisterHotKey(hwnd,hotKey_id);
}
三、重寫WndProc方法,實現注冊 protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
switch(m.Msg)
{
case WM_HOTKEY: //窗口消息-熱鍵
switch(m.WParam.ToInt32())
{
case 32: //熱鍵ID
MessageBox.Show("Hot Key : Ctrl + Alt + Shift + Space");
break;
?? default:
?? break;
}
break;
case WM_CREATE: //窗口消息-創建
RegKey(Handle,Space,MOD_ALT | MOD_CONTROL | MOD_SHIFT,VK_SPACE); //注冊熱鍵
break;
case WM_DESTROY: //窗口消息-銷毀
UnRegKey(Handle,Space); //銷毀熱鍵
break;
default:
break;
}
}
附:虛擬鍵值表
{ Virtual Keys, Standard Set }
{$EXTERNALSYM VK_LBUTTON}
VK_LBUTTON = 1;
{$EXTERNALSYM VK_RBUTTON}
VK_RBUTTON = 2;
{$EXTERNALSYM VK_CANCEL}
VK_CANCEL = 3;
{$EXTERNALSYM VK_MBUTTON}
VK_MBUTTON = 4; { NOT contiguous with L & RBUTTON }
{$EXTERNALSYM VK_BACK}
VK_BACK = 8;
{$EXTERNALSYM VK_TAB}
VK_TAB = 9;
{$EXTERNALSYM VK_CLEAR}
VK_CLEAR = 12;
{$EXTERNALSYM VK_RETURN}
VK_RETURN = 13;
{$EXTERNALSYM VK_SHIFT}
VK_SHIFT = $10;
{$EXTERNALSYM VK_CONTROL}
VK_CONTROL = 17;
{$EXTERNALSYM VK_MENU}
VK_MENU = 18;
{$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;
{$EXTERNALSYM VK_F20}
VK_F20 = 131;
{$EXTERNALSYM VK_F21}
VK_F21 = 132;
{$EXTERNALSYM VK_F22}
VK_F22 = 133;
{$EXTERNALSYM VK_F23}
VK_F23 = 134;
{$EXTERNALSYM VK_F24}
VK_F24 = 135;
{$EXTERNALSYM VK_NUMLOCK}
VK_NUMLOCK = 144;
{$EXTERNALSYM VK_SCROLL}
VK_SCROLL = 145;
{ VK_L & VK_R - left and right Alt, Ctrl and Shift virtual keys.
Used only as parameters to GetAsyncKeyState() and GetKeyState().
No other API or message will distinguish left and right keys in this way. }
{$EXTERNALSYM VK_LSHIFT}
VK_LSHIFT = 160; 84.菜單勾選/取消完成后關閉計算機
/*
using System.Runtime.InteropServices;
??????? [StructLayout(LayoutKind.Sequential, Pack = 1)]
??????? internal struct TokPriv1Luid
??????? {
??????????? public int Count;
??????????? public long Luid;
??????????? public int Attr;
??????? }
??????? [DllImport("kernel32.dll", ExactSpelling = true)]
??????? internal static extern IntPtr GetCurrentProcess();
?
??????? [DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
??????? internal static extern bool OpenProcessToken(IntPtr h, int acc, ref?? IntPtr phtok);
?
??????? [DllImport("advapi32.dll", SetLastError = true)]
??????? internal static extern bool LookupPrivilegeValue(string host, string name, ref?? long pluid);
?
??????? [DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
??????? internal static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall, ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen);
?
??????? [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
??????? internal static extern bool ExitWindowsEx(int flg, int rea);
?
??????? internal const int SE_PRIVILEGE_ENABLED = 0x00000002;
??????? internal const int TOKEN_QUERY = 0x00000008;
??????? internal const int TOKEN_ADJUST_PRIVILEGES = 0x00000020;
??????? internal const string SE_SHUTDOWN_NAME = "SeShutdownPrivilege";
??????? internal const int EWX_SHUTDOWN = 0x00000001;
??????? internal const int EWX_POWEROFF = 0x00000008;
??????? internal const int EWX_FORCE = 0x00000004;
??????? internal const int EWX_FORCEIFHUNG = 0x00000010;
*/
int flg=EWX_FORCE | EWX_POWEROFF;
??????????? bool ok;
??????????? TokPriv1Luid tp;
??????????? IntPtr hproc = GetCurrentProcess();
??????????? IntPtr htok = IntPtr.Zero;
??????????? k = OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref?? htok);
??????????? tp.Count = 1;
??????????? tp.Luid = 0;
??????????? tp.Attr = SE_PRIVILEGE_ENABLED;
??????????? k = LookupPrivilegeValue(null, SE_SHUTDOWN_NAME, ref?? tp.Luid);
??????????? k = AdjustTokenPrivileges(htok, false, ref?? tp, 0, IntPtr.Zero, IntPtr.Zero);
??????????? k = ExitWindowsEx(flg, 0); 85.菜單勾選/取消完成后重新啟動計算機
/*
using System.Runtime.InteropServices;
??????? [StructLayout(LayoutKind.Sequential, Pack = 1)]
??????? internal struct TokPriv1Luid
??????? {
??????????? public int Count;
??????????? public long Luid;
??????????? public int Attr;
??????? }
??????? [DllImport("kernel32.dll", ExactSpelling = true)]
??????? internal static extern IntPtr GetCurrentProcess();
?
??????? [DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
??????? internal static extern bool OpenProcessToken(IntPtr h, int acc, ref?? IntPtr phtok);
?
??????? [DllImport("advapi32.dll", SetLastError = true)]
??????? internal static extern bool LookupPrivilegeValue(string host, string name, ref?? long pluid);
?
??????? [DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
??????? internal static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall, ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen);
?
??????? [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
??????? internal static extern bool ExitWindowsEx(int flg, int rea);
?
??????? internal const int SE_PRIVILEGE_ENABLED = 0x00000002;
??????? internal const int TOKEN_QUERY = 0x00000008;
??????? internal const int TOKEN_ADJUST_PRIVILEGES = 0x00000020;
??????? internal const string SE_SHUTDOWN_NAME = "SeShutdownPrivilege";
??????? internal const int EWX_SHUTDOWN = 0x00000001;
??????? internal const int EWX_REBOOT = 0x00000002;
??????? internal const int EWX_FORCE = 0x00000004;
??????? internal const int EWX_FORCEIFHUNG = 0x00000010;
*/
int flg=EWX_FORCE | EWX_REBOOT;
??????????? bool ok;
??????????? TokPriv1Luid tp;
??????????? IntPtr hproc = GetCurrentProcess();
??????????? IntPtr htok = IntPtr.Zero;
??????????? k = OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref?? htok);
??????????? tp.Count = 1;
??????????? tp.Luid = 0;
??????????? tp.Attr = SE_PRIVILEGE_ENABLED;
??????????? k = LookupPrivilegeValue(null, SE_SHUTDOWN_NAME, ref?? tp.Luid);
??????????? k = AdjustTokenPrivileges(htok, false, ref?? tp, 0, IntPtr.Zero, IntPtr.Zero);
??????????? k = ExitWindowsEx(flg, 0); 86.菜單勾選/取消完成后注銷計算機
/*
using System.Runtime.InteropServices;
??????? [StructLayout(LayoutKind.Sequential, Pack = 1)]
??????? internal struct TokPriv1Luid
??????? {
??????????? public int Count;
??????????? public long Luid;
??????????? public int Attr;
??????? }
??????? [DllImport("kernel32.dll", ExactSpelling = true)]
??????? internal static extern IntPtr GetCurrentProcess();
?
??????? [DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
??????? internal static extern bool OpenProcessToken(IntPtr h, int acc, ref?? IntPtr phtok);
?
??????? [DllImport("advapi32.dll", SetLastError = true)]
??????? internal static extern bool LookupPrivilegeValue(string host, string name, ref?? long pluid);
?
??????? [DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
??????? internal static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall, ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen);
?
??????? [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
??????? internal static extern bool ExitWindowsEx(int flg, int rea);
?
??????? internal const int SE_PRIVILEGE_ENABLED = 0x00000002;
??????? internal const int TOKEN_QUERY = 0x00000008;
??????? internal const int TOKEN_ADJUST_PRIVILEGES = 0x00000020;
??????? internal const string SE_SHUTDOWN_NAME = "SeShutdownPrivilege";
??????? internal const int EWX_SHUTDOWN = 0x00000001;
??????? internal const int EWX_LOGOFF = 0x00000000;
??????? internal const int EWX_FORCE = 0x00000004;
??????? internal const int EWX_FORCEIFHUNG = 0x00000010;
*/
int flg=EWX_FORCE | EWX_LOGOFF;
??????????? bool ok;
??????????? TokPriv1Luid tp;
??????????? IntPtr hproc = GetCurrentProcess();
??????????? IntPtr htok = IntPtr.Zero;
??????????? k = OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref?? htok);
??????????? tp.Count = 1;
??????????? tp.Luid = 0;
??????????? tp.Attr = SE_PRIVILEGE_ENABLED;
??????????? k = LookupPrivilegeValue(null, SE_SHUTDOWN_NAME, ref?? tp.Luid);
??????????? k = AdjustTokenPrivileges(htok, false, ref?? tp, 0, IntPtr.Zero, IntPtr.Zero);
??????????? k = ExitWindowsEx(flg, 0); 87.菜單勾選/取消開機自啟動程序
?public void RunWhenStart(bool Started)
??????? {
string name=%%1;
string path=Application.ExecutablePath;
??????????? RegistryKey HKLM = Registry.LocalMachine;
??????????? RegistryKey Run = HKLM.CreateSubKey(@"SOFTWARE/Microsoft/Windows/CurrentVersion/Run/");
??????????? if (Started == true)
??????????? {
?????????????? try
??????????????? {
??????????????????? Run.SetValue(name, path);
??????????????????? HKLM.Close();
??????????????? }
??????????????? catch (Exception)
??????????????? {
??????????????????? MessageBox.Show("注冊表修改錯誤(開機自啟未實現)");
????????????? }
??????????? }
??????????? else
??????????? {
??????????????? try
??????????????? {
??????????????????? if (Run.GetValue(name) != null)
?????????????????? {
??????????????????????? Run.DeleteValue(name);
????????????????????? HKLM.Close();
?????????????????? }
??????????????????? else
??????????????????????? return;
??????????????? }
?????????????? catch (Exception e)
?????????????? {
?????????????????? //ExceptionTransact.WriteErrLog(base.GetType().Name, e.Message);
MessageBox(e.Message);
?????????????? }
?????????? }
??????? } 88.菜單勾選/取消自動登錄系統 89.模擬鍵盤輸入字符串
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using KenZhang.Free.VirtualInput;
using System.Runtime.InteropServices; namespace VirtualInputDemo
{
??? public partial class Form1 : Form
??? {
??????? public const int INPUT_KEYBOARD = 1;
??????? public const int KEYEVENTF_KEYUP = 0x0002;
??????? [DllImport("user32.dll")]
??????? public static extern UInt32 SendInput(UInt32 nInputs, ref INPUT pInputs, int cbSize);
??????? [StructLayout(LayoutKind.Explicit)]
??????? public struct INPUT
??????? {
??????????? [FieldOffset(0)]
??????????? public Int32 type;
??????????? [FieldOffset(4)]
??????????? public KEYBDINPUT ki;
??????????? [FieldOffset(4)]
??????????? public MOUSEINPUT mi;
??????????? [FieldOffset(4)]
??????????? public HARDWAREINPUT hi;
??????? }
??????? [StructLayout(LayoutKind.Sequential)]
??????? public struct MOUSEINPUT
??????? {
??????????? public Int32 dx;
??????????? public Int32 dy;
??????????? public Int32 mouseData;
??????????? public Int32 dwFlags;
??????????? public Int32 time;
??????????? public IntPtr dwExtraInfo;
??????? }
??????? [StructLayout(LayoutKind.Sequential)]
??????? public struct KEYBDINPUT
??????? {
??????????? public Int16 wVk;
??????????? public Int16 wScan;
??????????? public Int32 dwFlags;
??????????? public Int32 time;
??????????? public IntPtr dwExtraInfo;
??????? }
??????? [StructLayout(LayoutKind.Sequential)]
??????? public struct HARDWAREINPUT
??????? {
??????????? public Int32 uMsg;
??????????? public Int16 wParamL;
??????????? public Int16 wParamH;
??????? } public Form1()
??????? {
??????????? InitializeComponent();
??????? } private void button1_Click(object sender, EventArgs e)
??????? {
??????????? textBox1.Focus();
??????????? INPUT inDown = new INPUT();
??????????? inDown.type = INPUT_KEYBOARD;
??????????? inDown.ki.wVk = (int)Keys.A;
??????????? //INPUT inUp = new INPUT();
??????????? //inUp.type = INPUT_KEYBOARD;
??????????? //inUp.ki.wVk = (int)Keys.A;
??????????? //inUp.ki.dwFlags = KEYEVENTF_KEYUP;
??????????? SendInput(1, ref? inDown, Marshal.SizeOf(inDown));
??????????? //SendInput(1, ref? inUp, Marshal.SizeOf(inUp));
??????? }
??? }
} 90.提取PDF文件中的文本
xpdf
?? public partial class Form1 : Form
??? {
??????? public OpenFileDialog fdlg = new OpenFileDialog();//打開文件對話框
??????? public string filename; public Form1()
??????? {
??????????? InitializeComponent();
??????? } private void button1_Click(object sender, EventArgs e)
??????? {
??????????? ofdlg.Filter = "pdf文件(*.pdf)|*.pdf";//選擇pdf文件
??????????? if (ofdlg.ShowDialog() == DialogResult.OK)
??????????? {
??????????????? filename = string.Format("{0}", ofdlg.FileName);
??????????? }???????????
??????? }
      //傳送打開文件對話框中得到的filename來做為外部程序的參數來做轉化
??????? private void button2_Click(object sender, EventArgs e)
??????? {
??????????? Process p = new Process();
??????????? string path = "pdftotext.exe"; //進程啟用外部程序
???????????                 //這個exe我放在debug文件夾下面???????
??????????? p.StartInfo.FileName = path;
??????????? p.StartInfo.Arguments = string.Format( filename + " -");//很怪異的一行
??????????                        //參數“-”表示可以得到輸出流
??????????? p.StartInfo.UseShellExecute = false;
??????????? p.StartInfo.RedirectStandardInput = true;
??????????? p.StartInfo.RedirectStandardOutput = true;
??????????? p.StartInfo.RedirectStandardError = true;
??????????? p.StartInfo.CreateNoWindow = true;
???????????
??????????? p.Start();
??????????? string s = p.StandardOutput.ReadToEnd();//得到pdf文檔中的文本內容
??????????? textBox1.Text = s;
??????????? p.Close();
??????? }
??? }
}
上面的程序運行后,如果是在Debug文件夾下的pdf文件就可以得到輸出,可是如果在打開文件對話框中打開我桌面上的一個pdf如:@"d:/我的文檔/test.pdf",輸出就會是空,但是如果把上面那怪異的一行改為:
C# code
p.StartInfo.Arguments = string.Format( @"d:/我的文檔/test.pdf" + " -");
程序就又會得到輸出。
呵呵,謝謝樓上的兄臺,下載的xpdf中xpdftotext.exe用到的配置文件xpdfrc需要手動配置,我如果把那些字體啊,什么的映射成絕對路徑下的文件,就不會出現上面的問題,但是我把配置文件中的路徑改成了相對路徑,于是就出現了上面的問題了,看兄臺能夠很輕易的就運行成功,一定是做過很多代碼的,這里還得勞煩兄臺再給看一下,幫下忙,能遇到一個大神不容易,大神可不能吝嗇啊,先謝過了哈 91.操作內存映射文件
/*
using System.Runtime.InteropServices;
[DllImport("kernel32.dll")]
public static extern IntPtr CreateFileMapping(IntPtr hFile,
??? IntPtr lpFileMappingAttributes, uint flProtect,
??? uint dwMaximumSizeHigh,
??? uint dwMaximumSizeLow, string lpName); [DllImport("kernel32.dll")]
public static extern IntPtr MapViewOfFile(IntPtr hFileMappingObject, uint
??? dwDesiredAccess, uint dwFileOffsetHigh, uint dwFileOffsetLow,
??? IntPtr dwNumberOfBytesToMap); [DllImport("kernel32.dll")]
public static extern bool UnmapViewOfFile(IntPtr lpBaseAddress); [DllImport("kernel32.dll")]
public static extern bool CloseHandle(IntPtr hObject); [DllImport("kernel32.dll")]
public static extern IntPtr CreateFile(string lpFileName,
??? int dwDesiredAccess, FileShare dwShareMode, IntPtr securityAttrs,
??? FileMode dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile); [DllImport("kernel32.dll")]
public static extern uint GetFileSize(IntPtr hFile, IntPtr lpFileSizeHigh); public const int GENERIC_READ = -2147483648; //0x80000000
public const int GENERIC_WRITE = 0x40000000;
public const int GENERIC_EXECUTE = 0x20000000;
public const int GENERIC_ALL = 0x10000000;
public const int FILE_ATTRIBUTE_NORMAL = 0x80;
public const int FILE_FLAG_SEQUENTIAL_SCAN = 0x8000000;
public const int INVALID_HANDLE_VALUE = -1; public const int PAGE_NOACCESS = 1;
public const int PAGE_READONLY = 2;
public const int PAGE_READWRITE = 4; public const int FILE_MAP_COPY = 1;
public const int FILE_MAP_WRITE = 2;
public const int FILE_MAP_READ = 4;
*/
??? IntPtr vFileHandle = CreateFile(@"c:/temp/temp.txt",
??????? GENERIC_READ | GENERIC_WRITE, FileShare.Read | FileShare.Write,
??????? IntPtr.Zero,? FileMode.Open,
??????? FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, IntPtr.Zero);
??? if (INVALID_HANDLE_VALUE != (int)vFileHandle)
??? {
??????? IntPtr vMappingHandle = CreateFileMapping(
??????????? vFileHandle, IntPtr.Zero, PAGE_READWRITE, 0, 0, "~MappingTemp");
??????? if (vMappingHandle != IntPtr.Zero)
??????? {
??????????? IntPtr vHead = MapViewOfFile(vMappingHandle,
??????????????? FILE_MAP_COPY | FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, IntPtr.Zero);
??????????? if (vHead != IntPtr.Zero)
??????????? {
??????????????? uint vSize = GetFileSize(vFileHandle, IntPtr.Zero);
??????????????? for (int i = 0; i <= vSize / 2; i++)
??????????????? {
??????????????????? byte vTemp = Marshal.ReadByte((IntPtr)((int)vHead + i));
??????????????????? Marshal.WriteByte((IntPtr)((int)vHead + i),
??????????????????????? Marshal.ReadByte((IntPtr)((int)vHead + vSize - i - 1)));
??????????????????? Marshal.WriteByte((IntPtr)((int)vHead + vSize - i - 1), vTemp);
??????????????? }
??????????????? UnmapViewOfFile(vHead);
??????????? }
??????????? CloseHandle(vMappingHandle);
??????? }
??????? CloseHandle(vFileHandle);
??? } 92.重定向windows控制臺程序的輸出信息
????? delegate void dReadLine(string strLine);
??????? private void excuteCommand(string strFile, string args, dReadLine onReadLine)
??????? {
???????????? System.Diagnostics.Process p = new System.Diagnostics.Process();
???????????? p.StartInfo = new System.Diagnostics.ProcessStartInfo();
???????????? p.StartInfo.FileName = strFile;
???????????? p.StartInfo.Arguments = args;
???????????? p.StartInfo.WindowStyle. = System.Diagnostics.ProcessWindowStyle.Hidden;
???????????? p.StartInfo.RedirectStandardOutput = true;
???????????? p.StartInfo.UseShellExecute = false;
???????????? p.StartInfo.CreateNoWindow = true;
???????????? p.Start();
???????????? System.IO.StreamReader reader = p.StandardOutput;//截取輸出流
??????????? string line = reader.ReadLine();//每次讀取一行
??????????? while (!reader.EndOfStream)
??????????? {
???????????????? onReadLine(line);
???????????????? line = reader.ReadLine();
???????????? }
???????????? p.WaitForExit();
???????? }
??????? private void PrintMessage(string strLine)
??????? {
??????????? this.textBox1.Text += strLine + " ";
???????? }
???????????? excuteCommand("ipconfig", "", new dReadLine(PrintMessage)); 93.接受郵件 94.發送郵件
using System;
using System.Net.Sockets;
using System.Net;
using System.Security.Cryptography;
using System.IO;
// 類名:Pop3
// 功能:接收電子郵件 namespace ZTSX.Email
{
/// <summary>
/// Pop3 的摘要說明。
/// </summary>
public class Pop3
{
private string mstrHost???? = null; //主機名稱或IP地址
private int mintPort???? = 110; //主機的端口號(默認為110)
private TcpClient mtcpClient?? = null; //客戶端
private NetworkStream mnetStream = null; //網絡基礎數據流
private StreamReader m_stmReader = null; //讀取字節流
private string mstrStatMessage?? = null; //執行STAT命令后得到的消息(從中得到郵件數) /// <summary>
/// 構造函數
/// </summary>
/// <remarks>一個郵件接收對象</remarks>
public Pop3()
{
} /// <summary>
/// 構造函數
/// </summary>
/// <param name="host">主機名稱或IP地址</param>
public Pop3(string host)
{
?? mstrHost = host;
} /// <summary>
/// 構造函數
/// </summary>
/// <param name="host">主機名稱或IP地址</param>
/// <param name="port">主機的端口號</param>
/// <remarks>一個郵件接收對象</remarks>
public Pop3(string host,int port)
{
?? mstrHost = host;
?? mintPort = port;
} #region 屬性 /// <summary>
/// 主機名稱或IP地址
/// </summary>
/// <remarks>主機名稱或IP地址</remarks>
public string HostName
{
?? get{return mstrHost;}
?? set{mstrHost = value;}
} /// <summary>
/// 主機的端口號
/// </summary>
/// <remarks>主機的端口號</remarks>
public int Port
{
?? get{return mintPort;}
?? set{mintPort = value;}
} #endregion #region 私有方法 /// <summary>
/// 向網絡訪問的基礎數據流中寫數據(發送命令碼)
/// </summary>
/// <param name="netStream">可以用于網絡訪問的基礎數據流</param>
/// <param name="command">命令行</param>
/// <remarks>向網絡訪問的基礎數據流中寫數據(發送命令碼)</remarks>
private void WriteToNetStream(ref NetworkStream netStream,String command)
{
?? string strToSend = command + "/r/n";
?? byte[] arrayToSend = System.Text.Encoding.ASCII.GetBytes(strToSend.ToCharArray());
????? netStream.Write(arrayToSend,0,arrayToSend.Length);
} /// <summary>
/// 檢查命令行結果是否正確
/// </summary>
/// <param name="message">命令行的執行結果</param>
/// <param name="check">正確標志</param>
/// <returns>
/// 類型:布爾
/// 內容:true表示沒有錯誤,false為有錯誤
/// </returns>
/// <remarks>檢查命令行結果是否有錯誤</remarks>
private bool CheckCorrect(string message,string check)
{
?? if(message.IndexOf(check) == -1)
??? return false;
?? else
??? return true;
} /// <summary>
/// 郵箱中的未讀郵件數
/// </summary>
/// <param name="message">執行完LIST命令后的結果</param>
/// <returns>
/// 類型:整型
/// 內容:郵箱中的未讀郵件數
/// </returns>
/// <remarks>郵箱中的未讀郵件數</remarks>
private int GetMailNumber(string message)
{
?? string[] strMessage = message.Split(' ');
?? return Int32.Parse(strMessage[1]);
} /// <summary>
/// 得到經過解碼后的郵件的內容
/// </summary>
/// <param name="encodingContent">解碼前的郵件的內容</param>
/// <returns>
/// 類型:字符串
/// 內容:解碼后的郵件的內容
/// </returns>
/// <remarks>得到解碼后的郵件的內容</remarks>
private string GetDecodeMailContent(string encodingContent)
{
?? string strContent = encodingContent.Trim();
?? string strEncode = null; int iStart = strContent.IndexOf("Base64");
?? if(iStart == -1)
??? throw new Pop3Exception("郵件內容不是Base64編碼,請檢查");
?? else
?? {
??? strEncode = strContent.Substring(iStart + 6,strContent.Length - iStart - 6);
??? try
??? {
???? return SX.Encode.TransformToString(strEncode);
??? }
??? catch(SX.EncodeException exc)
??? {
???? throw new Pop3Exception(exc.Message);
??? }
?? }
} #endregion /// <summary>
/// 與主機建立連接
/// </summary>
/// <returns>
/// 類型:布爾
/// 內容:連接結果(true為連接成功,false為連接失敗)
/// </returns>
/// <remarks>與主機建立連接</remarks>
public bool Connect()
{
?? if(mstrHost == null)
??? throw new Exception("請提供SMTP主機名稱或IP地址!");
?? if(mintPort == 0)
??? throw new Exception("請提供SMTP主機的端口號");
?? try
?? {
??? mtcpClient = new TcpClient(mstrHost,mintPort);
??? mnetStream = mtcpClient.GetStream();
??? m_stmReader = new StreamReader(mtcpClient.GetStream()); string strMessage = m_stmReader.ReadLine();
??? if(CheckCorrect(strMessage,"+OK") == true)
???? return true;
??? else
???? return false;
?? }
?? catch(SocketException exc)
?? {
??? throw new Pop3Exception(exc.ToString());
?? }
?? catch(NullReferenceException exc)
?? {
??? throw new Pop3Exception(exc.ToString());
?? }
} #region Pop3命令 /// <summary>
/// 執行Pop3命令,并檢查執行的結果
/// </summary>
/// <param name="command">Pop3命令行</param>
/// <returns>
/// 類型:字符串
/// 內容:Pop3命令的執行結果
/// </returns>
private string ExecuteCommand(string command)
{
?? string strMessage = null; //執行Pop3命令后返回的消息 try
?? {
??? //發送命令
??? WriteToNetStream(ref mnetStream,command); //讀取多行
??? if(command.Substring(0,4).Equals("LIST") || command.Substring(0,4).Equals("RETR") || command.Substring(0,4).Equals("UIDL")) //記錄STAT后的消息(其中包含郵件數)
??? {
???? strMessage = ReadMultiLine(); if(command.Equals("LIST")) //記錄LIST后的消息(其中包含郵件數)
????? mstrStatMessage = strMessage;
??? }
???? //讀取單行
??? else
???? strMessage = m_stmReader.ReadLine(); //判斷執行結果是否正確
??? if(CheckCorrect(strMessage,"+OK"))
???? return strMessage;
??? else
???? return "Error";
?? }
?? catch(IOException exc)
?? {
??? throw new Pop3Exception(exc.ToString());
?? }
} /// <summary>
/// 在Pop3命令中,LIST、RETR和UIDL命令的結果要返回多行,以點號(.)結尾,
/// 所以如果想得到正確的結果,必須讀取多行
/// </summary>
/// <returns>
/// 類型:字符串
/// 內容:執行Pop3命令后的結果
/// </returns>
private string ReadMultiLine()
{
?? string strMessage = m_stmReader.ReadLine();
?? string strTemp = null;
?? while(strMessage != ".")
?? {
??? strTemp = strTemp + strMessage;
??? strMessage = m_stmReader.ReadLine();
?? }
?? return strTemp;
} //USER命令
private string USER(string user)
{
?? return ExecuteCommand("USER " + user) + "/r/n";
} //PASS命令
private string PASS(string password)
{
?? return ExecuteCommand("PASS " + password) + "/r/n";
} //LIST命令
private string LIST()
{
?? return ExecuteCommand("LIST") + "/r/n";
} //UIDL命令
private string UIDL()
{
?? return ExecuteCommand("UIDL") + "/r/n";
} //NOOP命令
private string NOOP()
{
?? return ExecuteCommand("NOOP") + "/r/n";
} //STAT命令
private string STAT()
{
?? return ExecuteCommand("STAT") + "/r/n";
} //RETR命令
private string RETR(int number)
{
?? return ExecuteCommand("RETR " + number.ToString()) + "/r/n";
} //DELE命令
private string DELE(int number)
{
?? return ExecuteCommand("DELE " + number.ToString()) + "/r/n";
} //QUIT命令
private void Quit()
{
?? WriteToNetStream(ref mnetStream,"QUIT");
} /// <summary>
/// 收取郵件
/// </summary>
/// <param name="user">用戶名</param>
/// <param name="password">口令</param>
/// <returns>
/// 類型:字符串數組
/// 內容:解碼前的郵件內容
/// </returns>
private string[] ReceiveMail(string user,string password)
{
?? int iMailNumber = 0; //郵件數 if(USER(user).Equals("Error"))
??? throw new Pop3Exception("用戶名不正確!");
?? if(PASS(password).Equals("Error"))
??? throw new Pop3Exception("用戶口令不正確!");
?? if(STAT().Equals("Error"))
??? throw new Pop3Exception("準備接收郵件時發生錯誤!");
?? if(LIST().Equals("Error"))
??? throw new Pop3Exception("得到郵件列表時發生錯誤!"); try
?? {
??? iMailNumber = GetMailNumber(mstrStatMessage); //沒有新郵件
??? if(iMailNumber == 0)
???? return null;
??? else
??? {
???? string[] strMailContent = new string[iMailNumber]; for(int i = 1 ; i <= iMailNumber ; i++)
???? {
????? //讀取郵件內容
????? strMailContent[i - 1] = GetDecodeMailContent(RETR(i));
???? }
???? return strMailContent;
??? }
?? }
?? catch(Pop3Exception exc)
?? {
??? throw new Pop3Exception(exc.ToString());
?? }
} #endregion
/// <summary>
/// 收取郵件????
/// </summary>
/// <param name="user">用戶名</param>
/// <param name="password">口令</param>
/// <returns>
/// 類型:字符串數組
/// 內容:解碼前的郵件內容
/// </returns>
///<remarks>收取郵箱中的未讀郵件</remarks>
public string[] Receive(string user,string password)
{
?? try
?? {
??? return ReceiveMail(user,password);
?? }
?? catch(Pop3Exception exc)
?? {
??? throw new Pop3Exception(exc.ToString());
?? }
} /// <summary>
/// 斷開所有與服務器的會話
/// </summary>
/// <remarks>斷開所有與服務器的會話</remarks>
public void DisConnect()
{
?? try
?? {
??? Quit();
??? if(m_stmReader != null)
???? m_stmReader.Close();
??? if(mnetStream != null)
???? mnetStream.Close();
??? if(mtcpClient != null)
???? mtcpClient.Close();
?? }
?? catch(SocketException exc)
?? {
??? throw new Pop3Exception(exc.ToString());
?? }
} /// <summary>
/// 刪除郵件
/// </summary>
/// <param name="number">郵件號</param>
public void DeleteMail(int number)
{
?? //刪除郵件
?? int iMailNumber = number + 1;
?? if(DELE(iMailNumber).Equals("Error"))
??? throw new Pop3Exception("刪除第" + iMailNumber.ToString() + "時出現錯誤!");
} }
} 95.報表相關
/*
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
*/
2、水晶報表的兩種格式
?? 1)pull模式,不利用DataSet,直接從數據庫中取出數據
?? 2) push模式,使用DataSet,利用它進行數據的加載和處理等
3. 水晶報表使用的庫
?? 1)水晶報表的引擎(CREnging.dll),作用:合并數據,裝換格式
?? 2)水晶報表設計器(CRDesigner.dll),作用:設計標題,插入數據等
?? 3)水晶報表查看控件(CRWebFormViewer.DLL)
?? 4)需要引入的命名空間
???? using CrystalDecisions.CrystalReports.Engine;
???? using CrystalDecisions.Shared;
4、Pull模式下使用水晶報表
?? 1)創建rpt文件
?? 2)拖放CrystalReportViewer
?? 3)綁定
5、讀取水晶報表文件
?? private void ReadCRV(cryatalReportViewer crv)
?? {
???? openFileDialog dlg=new OpenFileDialog();
???? dlg.Title="打開水晶報表文件";
???? dlg.Filter="水晶報表文件(*.rpt)|*.rpt|所有文件|*.*";
???? if(dlg.showDialog()==DialogResult.OK)
???? {
?????? crv.ReportSource=dlg.FileName;
???? }
?? }
6. B/S下讀取報表的文件
??? private void ReadCRV(cryatalReportViewer crv,File file)
??? {
????? string strName=file.PostedFile.FileName;
????? if(strName.Trim()!="")
????? {
??????? crv.ReportSource=strName
??????? Session["fileName"]=strName;
????? }
??? }
??? 在B/S中要防止數據源的丟失
??? priavte void Page_Load(object sender,System.EventArgs e)
??? {
????? if(Session["fileName"]!=null)
????? {
??????? crv.ReportSource=Session["fileName"].ToString();
????? }
??? }
7. 假如直接從數據庫中讀取數據,采用PULL模式可能出現錯誤(登錄的用戶名和密碼不對)
?? private void ReadCRV(CrystalReportViewer crv,CrystalReport cr)
?? {
????? ReportDocument reportDoc=new ReportDocument();
????? reportDoc.Load(Server.MapPath(cr));//要加載的rpt文件的名字
????? //解決登錄的問題
????? TableLogOnInfo logonInfo = new TableLogOnInfo();
????? foreach(Table tb in ReportDoc.Database.Tables)
????? {
??????? logonInfo=tb.LogOnInfo;
??????? logonInfo.ConnectionInfo.ServerName="(loacl)";
??????? logonInfo.ConnectionInfo.DatabaseName="Pubs";
??????? logonInfo.ConnectionInfo.UserId="sa";
??????? logonInfo.ConnectionInfo.Password="";
??????? tb.ApplyLogOnInfo(logonInfo);
????? }
????? crv.ReportSource=reportDoc;
?? }
8. 采用Push模式,直接在數據源讀取
?? private void BindReport(CrystalReportViewer crv)
?? {
???? string strProvider="Server=(local);DataBase=pubs;uid=sa;pwd=";
???? CrystalReport cr=new CrystalReport();
???? DataSet ds=new DataSet();
???? SqlConnection conn=new SqlConnection(strProvider);
???? conn.open();
???? string strSql="select * from jobs";
???? SqlDataAdapter dap=new SqlDataAdapter(strSql,conn);
???? adp.Fill(ds,"jobs");
???? cr.SetDataSource(ds);
???? crv.ReportSource=cr;
?? }
9. 導出水晶報表的文件
?? private void ExportCrv(CrystalReport cr)
?? {
????? DiskFileDestionOptions dOpt=new DiskFileDestionOptions();
????? cr.ExportOptions.ExportDestinationType=ExportDestinationType.DiskFile();
????? cr.ExportOptions.ExportFormatType= ExportFormatType.PortableDocFormat;
????? dOpt.DiskFileName="C:/output.pdf";
????? cr.ExportOptions.DestinationOptions=dOpt;
????? cr.Export();
?????
?? }
?? private void ExportCrv(CrystalReport cr,string strType,string strPath)
?? {
????? DiskFileDestionOptions dOpt=new DiskFileDestionOptions();
????? cr.ExportOptions.ExportDestinationType=ExportDestinationType.DiskFile();
????? switch(strType)
????? {
???????? case "RTF":
?????????? cr.ExportOptions.ExportFormatType=ExportFormatType.RichText;
?????????? dOpt.DiskFileName=strPath;
?????????? break;
???????? case "PDF":
?????????? cr.ExportOptions.ExportFormatType=ExportFormatType.PortableDocFormat;
?????????? dOpt.DiskFileName=strPath;
?????????? break;
???????? case "DOC":
?????????? cr.ExportOptions.ExportFormatType=ExportFormatType.WordForWindows;
?????????? dOpt.DiskFileName=strPath;
?????????? break;
???????? case "XLS":
?????????? cr.ExportOptions.ExportFormatType=ExportFormatType.Excel;
?????????? dOpt.DiskFileName=strPath;
?????????? break;
???????? default;
???????? break;
??????????
????? }
????? cr.ExportOptions.DestinationOptions=dOpt;
????? cr.Export(); }
10 B/S下水晶報表的打印
?? priavte void PrintCRV(CrystalReport cr)
?? {
???? stringstrPrinterName=@"printName";
???? PageMargins margins=cr.PrintOptions.PageMargins;
???? margins.bottomMargin = 250;
???? margins.leftMargin = 350;
???? margins.rightMargin = 350;
???? margins.topMargin = 450;
???? cr.PrintOptions.ApplyPageMargins(margins);
???? cr.PrintOptions.printerName=strPrinterName;
???? cr.PrintToPrinter(1,false,0,0)//參數設置為0,表示打印所用頁
?? } 96.全屏幕截取 /*
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;
using System.Collections;
using System.Drawing.Imaging;
using System.Threading;
*/
[DllImport("gdi32.dll")]
private static extern int BitBlt(IntPtr hdcDest,int nXDest,int nYDest,int nWidth,int nHeight,IntPtr hdcSrc,int nXSrc,int nYSrc,UInt32 dwRop);
??????????? //this.Hide();//如果你不想截取的圖象中有此應用程序
??????????? //Thread.Sleep(1000);
??????????? Rectangle rect = new Rectangle();
??????????? rect = Screen.GetWorkingArea(this);//獲得當前屏幕的大小??
??????????? Graphics g = this.CreateGraphics();
//創建一個以當前屏幕為模板的圖象??
??????????? Image myimage = new Bitmap(rect.Width, rect.Height, g);
//第二種得到全屏坐標的方法
???????? // Image myimage = new Bitmap(Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height,g);
//創建以屏幕大小為標準的位圖?
??????????? Graphics gg = Graphics.FromImage(myimage);
??????????? IntPtr dc = g.GetHdc();//得到屏幕的DC?
??????????? IntPtr dcdc = gg.GetHdc();//得到Bitmap的DC????
???????? BitBlt(dcdc, 0, 0, rect.Width, rect.Height, dc, 0, 0, 13369376);
//調用此API函數,實現屏幕捕獲??
??????????? g.ReleaseHdc(dc);//釋放掉屏幕的DC??
??????????? gg.ReleaseHdc(dcdc);//釋放掉Bitmap的DC????
??????????? myimage.Save(Application.StartupPath + @"/bob.jpg",??? ImageFormat.Jpeg);//以JPG文件格式來保存??
??????????? this.Show(); 97.區域截幕
/*
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;
using System.Collections;
using System.Drawing.Imaging;
using System.Threading;
?[DllImport("gdi32.dll")]
public static extern IntPtr CreateDC(
?string lpszDriver,??????? // driver name
?string lpszDevice,??????? // device name
?string lpszOutput,??????? // not used; should be NULL
?Int64 lpInitData? // optional printer data
?);
?
[DllImport("gdi32.dll")]
public static extern IntPtr CreateCompatibleDC(
?IntPtr hdc // handle to DC
?);
?
[DllImport("gdi32.dll")]
public static extern int GetDeviceCaps(
?IntPtr hdc,???? // handle to DC
?GetDeviceCapsIndex nIndex?? // index of capability
); [DllImport("gdi32.dll")]
public static extern IntPtr CreateCompatibleBitmap(
?IntPtr hdc,??????? // handle to DC
?int nWidth,???? // width of bitmap, in pixels
?int nHeight???? // height of bitmap, in pixels
?); [DllImport("gdi32.dll")]
public static extern IntPtr SelectObject(
?IntPtr hdc,????????? // handle to DC
?IntPtr hgdiobj?? // handle to object
?); [DllImport("gdi32.dll")]
public static extern int BitBlt(
?IntPtr hdcDest, // handle to destination DC
?int nXDest,? // x-coord of destination upper-left corner
?int nYDest,? // y-coord of destination upper-left corner
?int nWidth,? // width of destination rectangle
?int nHeight, // height of destination rectangle
?IntPtr hdcSrc,? // handle to source DC
?int nXSrc,?? // x-coordinate of source upper-left corner
?int nYSrc,?? // y-coordinate of source upper-left corner
?UInt32 dwRop? // raster operation code
?); [DllImport("gdi32.dll")]
public static extern int DeleteDC(
?IntPtr hdc????????? // handle to DC
?);
*/
public static Bitmap GetPartScreen(Point P1,Point P2,bool Full)
{
??? IntPtr hscrdc,hmemdc;
??? IntPtr hbitmap,holdbitmap;
??? int nx,ny,nx2,ny2;
??? nx=ny=nx2=ny2=0;
??? int nwidth, nheight;
??? int xscrn, yscrn;
??? hscrdc = CreateDC("DISPLAY", null, null, 0);//創建DC句柄
??? hmemdc = CreateCompatibleDC(hscrdc);//創建一個內存DC
??? xscrn = GetDeviceCaps(hscrdc, GetDeviceCapsIndex.HORZRES);//獲取屏幕寬度
??? yscrn = GetDeviceCaps(hscrdc, GetDeviceCapsIndex.VERTRES);//獲取屏幕高度
??? if(Full)//如果是截取整個屏幕
??? {
??????? nx = 0;
??????? ny = 0;
??????? nx2 = xscrn;
??????? ny2 = yscrn;
??? }
??? else
??? {
??????? nx = P1.X;
??????? ny = P1.Y;
??????? nx2 =P2.X;
??????? ny2 =P2.Y;
??????? //檢查數值合法性
??????? if(nx<0)nx = 0;
??????? if(ny<0)ny = 0;
??????? if(nx2>xscrn)nx2 = xscrn;
??????? if(ny2>yscrn)ny2 = yscrn;
??? }
??? nwidth = nx2 - nx;//截取范圍的寬度
??? nheight = ny2 - ny;//截取范圍的高度
??? hbitmap = CreateCompatibleBitmap(hscrdc, nwidth, nheight);//從內存DC復制到hbitmap句柄
??? holdbitmap = SelectObject(hmemdc, hbitmap);
??? BitBlt(hmemdc, 0, 0, nwidth, nheight,hscrdc, nx, ny,(UInt32)0xcc0020);
??? hbitmap = SelectObject(hmemdc, holdbitmap);
??? DeleteDC(hscrdc);//刪除用過的對象
??? DeleteDC(hmemdc);//刪除用過的對象
??? return Bitmap.FromHbitmap(hbitmap);//用Bitmap.FromHbitmap從hbitmap返回Bitmap
} 98.計算文件MD5值
/*
using System.IO;
using System.Security.Cryptography;
*/
string path = %%1;
FileStream fs = new FileStream(path,FileMode.Open,FileAccess.Read);
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
byte [] md5byte = md5.ComputeHash(fs);
int i,j;
StringBuilder sb = new StringBuilder(16);
foreach (byte b in md5byte)
{
 ?? i = Convert.ToInt32(b);
   j = i >> 4;
   sb.Append(Convert.ToString(j,16));
   j = ((i << 4) & 0x00ff) >> 4;
   sb.Append(Convert.ToString(j,16));
}
string %%2=sb.ToString(); 99.計算獲取文件夾中文件的MD5值
/*
using System.IO;
using System.Security.Cryptography;
using System.Collections;
*/
bool b=false;
string path = (%%2.LastIndexOf("//") == %%2.Length - 1) ? %%2 : %%2 + "//";
string parent = Path.GetDirectoryName(%%1);
Directory.CreateDirectory(path + Path.GetFileName(%%1));
DirectoryInfo dir = new DirectoryInfo((%%1.LastIndexOf("//") == %%1.Length - 1) ? %%1 : %%1 + "//");
FileSystemInfo[] fileArr = dir.GetFileSystemInfos();
Queue<FileSystemInfo> Folders = new Queue<FileSystemInfo>(dir.GetFileSystemInfos());
while (Folders.Count > 0)
{
??? FileSystemInfo tmp = Folders.Dequeue();
??? FileInfo f = tmp as FileInfo;
??? if (b && f == null)
??? {
??????? DirectoryInfo d = tmp as DirectoryInfo;
??????? Directory.CreateDirectory(d.FullName.Replace((parent.LastIndexOf("//") == parent.Length - 1) ? parent : parent + "//", path));
??????? foreach (FileSystemInfo fi in d.GetFileSystemInfos())
??????? {
??????????? Folders.Enqueue(fi);
??????? }
??? }
??? else
??? {
??????? FileStream fs = new FileStream(f,FileMode.Open,FileAccess.Read);
??????? MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
??????? byte [] md5byte = md5.ComputeHash(fs);
??????? int i,j;
??????? StringBuilder sb = new StringBuilder(16);
??????? foreach (byte b in md5byte)
??????? {
???????  ?? i = Convert.ToInt32(b);
???????    j = i >> 4;
???????    sb.Append(Convert.ToString(j,16));
???????    j = ((i << 4) & 0x00ff) >> 4;
???????    sb.Append(Convert.ToString(j,16));
??????? }
??????? string %%3=sb.ToString();
??? }
}

總結

以上是生活随笔為你收集整理的代码集锦的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

激情av在线资源 | 久久人人爽人人爽人人片 | 日本久久久久久 | 国产精品 999| 亚洲三级视频 | 国产精品免费在线播放 | 91最新在线视频 | 国产精品一区二区久久久久 | 国产成人在线网站 | 国产成人一区二区三区久久精品 | 久久综合久久综合久久 | 欧美成年网站 | 成人午夜剧场在线观看 | 69久久夜色精品国产69 | 久久久久免费精品视频 | 久久国产精品久久w女人spa | 成人av电影免费在线观看 | 欧美性色综合网 | 亚洲美女久久 | 91视频88av | 国产又粗又猛又黄 | 一区二区三区高清不卡 | 91精品资源 | 国产美女网 | 在线观看免费av片 | 亚洲天堂激情 | 成人小视频在线观看免费 | 深爱激情综合网 | 黄色毛片一级片 | 亚在线播放中文视频 | 亚洲综合导航 | 欧美日韩国产精品一区二区三区 | 久久99精品久久久久久秒播蜜臀 | 免费观看的av | 手机av在线网站 | 国产精品女同一区二区三区久久夜 | 欧美人体xx| 国产精品女同一区二区三区久久夜 | 国产精品99久久免费观看 | 亚洲精品视频在线看 | 99精品在线视频播放 | 四川bbb搡bbb爽爽视频 | 精品久久美女 | 欧洲精品视频一区二区 | 丝袜美女视频网站 | 久久久91精品国产一区二区精品 | 国内久久 | 亚洲美女精品 | 丁香六月久久综合狠狠色 | 国内小视频在线观看 | 超碰在线天天 | 九九热视频在线免费观看 | 九九九热精品免费视频观看网站 | 日韩中文字幕网站 | 免费在线一区二区三区 | 久久久久激情电影 | 中文字幕在线播放一区二区 | 免费观看视频的网站 | 人人爽人人爽人人片av | 久久免费视频精品 | 最近中文字幕高清字幕在线视频 | 人人玩人人添人人澡97 | 久久国产精品99久久人人澡 | 国产在线探花 | 96超碰在线 | 99免费在线视频观看 | av在线免费在线 | www.天天色| 国产精品乱码一区二三区 | 精品久久99| 婷婷国产在线观看 | 日韩欧美在线不卡 | 午夜12点 | 在线成人小视频 | 一级片视频在线 | 一本一本久久a久久 | 四虎5151久久欧美毛片 | 在线观看久久 | 久久国产精品免费一区 | 久久av伊人| 丁香六月中文字幕 | 国产性天天综合网 | 91视频在线观看大全 | 在线中文字幕av观看 | 日韩欧美精品一区二区 | 五月婷久 | 69热国产视频 | 久久久久国产精品www | 精品网站999www | 欧美日韩精品电影 | 国产亚洲精品久久久久久久久久 | 一级黄色大片 | 中文字幕人成人 | 丰满少妇高潮在线观看 | 97偷拍视频 | 在线三级av| 午夜精品成人一区二区三区 | 在线视频 精品 | 久久在线精品视频 | 黄网站app在线观看免费视频 | 五月天中文在线 | 成人午夜精品久久久久久久3d | 91精品视频免费 | 国产日本高清 | www日日 | 91亚洲网 | 日本黄色免费大片 | 在线免费视频a | 国产精品一区二区在线免费观看 | 亚洲人成在 | 亚洲专区在线视频 | 亚洲欧美日韩国产一区二区三区 | 国产97在线观看 | 二区视频在线观看 | 一级c片| 久久免费公开视频 | 日韩专区在线观看 | 日韩理论电影在线观看 | 日韩av在线免费看 | 成人av资源网站 | 日韩精品中文字幕久久臀 | 五月天亚洲综合小说网 | 九九精品在线观看 | 精品自拍网 | 狠狠干狠狠艹 | 欧美色图亚洲图片 | 国产成人一区三区 | 日韩在线电影一区二区 | 久久精品视频网 | 欧美人牲 | 久久精品在线视频 | 五月婷婷在线综合 | 射射射综合网 | 亚洲精品一区中文字幕乱码 | 91精品国产高清自在线观看 | 中文字幕在线播放第一页 | 日韩视频免费 | 贫乳av女优大全 | 91精品国产99久久久久久红楼 | 韩国av免费在线 | www.在线观看视频 | 国产精品一区二区中文字幕 | 91视频免费看片 | 亚洲黄色片 | 成人 亚洲 欧美 | 亚洲涩涩色 | 免费看片成年人 | 国产精品一区二区av日韩在线 | 久久久久久久久久久免费 | www.av免费观看 | 国产在线观看99 | 有码中文字幕在线观看 | 探花视频在线观看+在线播放 | 搡bbbb搡bbb视频| 日本性视频 | 国产免费观看高清完整版 | 亚洲成人精品影院 | 久久久久久久久久影视 | 美女视频黄是免费的 | 久久成人人人人精品欧 | 亚洲欧洲精品一区二区 | 国产在线观看免费 | 99热只有精品在线观看 | 91久久精品一区二区二区 | 日韩电影中文字幕在线观看 | 在线观看爱爱视频 | 国产大片黄色 | 国产成人一区二区三区久久精品 | 日本中出在线观看 | 少妇bbbb搡bbbb搡bbbb | 日韩欧美一区二区三区黑寡妇 | 成人黄色电影免费观看 | 一区二区三区韩国免费中文网站 | 成人一级电影在线观看 | 久久精品九色 | 国产精品免费一区二区三区在线观看 | 国产视频九色蝌蚪 | 免费福利小视频 | 在线视频黄 | 免费高清在线视频一区· | 夜夜躁天天躁很躁波 | 免费欧美 | 国产精品一区二区 91 | 97在线视频免费播放 | 福利网在线 | 国产一级一片免费播放放a 一区二区三区国产欧美 | 麻豆91精品视频 | 网站免费黄 | 日韩精品三区四区 | 九九九在线 | 国产精品一区二区久久精品爱微奶 | 91女人18片女毛片60分钟 | 波多野结衣视频在线 | 欧美日韩国产在线 | 一级片免费视频 | 一区二区精品在线 | 国产精品美女免费 | 97在线视频免费 | 国产成人精品久久久久蜜臀 | 999亚洲国产996395 | 999精品| 97超级碰碰碰碰久久久久 | av中文字幕在线观看网站 | 亚洲午夜剧场 | 日韩电影在线观看一区二区三区 | 99草视频 | 国产亚洲婷婷免费 | 国产精久久久久久妇女av | 91精品婷婷国产综合久久蝌蚪 | 狠狠色丁香九九婷婷综合五月 | 超碰在线公开免费 | 午夜资源站 | 中文字幕制服丝袜av久久 | 亚洲综合在线五月天 | 国产精品激情在线观看 | 91在线影院 | 国产精品免费久久久久久久久久中文 | 欧美日韩另类视频 | 欧美在线资源 | 成人国产精品一区二区 | 久久综合一本 | 日韩极品视频在线观看 | 久久综合久久久久88 | 久久国产精品久久精品国产演员表 | 精品久久精品久久 | 99精品视频在线观看视频 | 欧美日韩观看 | 久久国内精品视频 | 伊人热 | 999久久 | 91成人在线观看喷潮 | 亚洲国产美女精品久久久久∴ | 国产中文字幕视频在线 | 五月天久久综合网 | 日日夜夜精品视频天天综合网 | 国产黄色精品在线 | 黄色网址a | 亚洲一区网站 | 伊人日日干 | 国产中文字幕视频在线观看 | 欧美日韩视频在线观看一区二区 | 六月激情 | 麻豆超碰 | 亚洲国产精品999 | 国内精品久久久久久久久 | 亚洲乱码精品久久久久 | 久久久 激情| 成人黄色片在线播放 | 日本中文字幕网站 | 国产精品一区电影 | 精品国产黄色片 | 97超碰在线久草超碰在线观看 | 99久久精品免费看国产 | 亚洲做受高潮欧美裸体 | 激情五月婷婷激情 | 99综合视频 | 在线高清av | 日韩精品国产一区 | 免费观看一级 | 婷婷色视频| 女人高潮特级毛片 | 日本特黄特色aaa大片免费 | 最新av免费在线观看 | 久久论理 | 91网在线| 97视频免费在线 | 99国产视频在线 | 中日韩三级视频 | 麻豆久久久久 | 欧美a级片网站 | 草莓视频在线观看免费观看 | 久久视频这里只有精品 | 久综合网| 在线成人高清电影 | 国产不卡视频在线 | 国产一区成人在线 | 操一草 | av日韩中文 | 日韩精品亚洲专区在线观看 | 久久在线观看视频 | 亚洲欧美婷婷六月色综合 | 欧美一级片免费在线观看 | 久久久激情视频 | 麻豆91在线观看 | 国产一二三四在线视频 | 亚洲综合欧美日韩狠狠色 | 国产视频资源 | 国产精品久久久久久久久久久杏吧 | www.天天操 | 欧美性生活久久 | 友田真希av| 精品国产一二三 | 国产小视频在线免费观看 | 国产精品1区 | 高清久久久| 亚洲日韩欧美视频 | 天天色天天干天天色 | 天天曰天天爽 | 天天干天天色2020 | 国产视频精品在线 | 成年人免费在线播放 | 成人av影院在线观看 | 91在线视频播放 | 成人毛片一区二区三区 | 天天干夜夜想 | 国产亚洲精品久久久久秋 | 亚洲九九精品 | 国产免费一区二区三区最新6 | 久久午夜鲁丝片 | 国产成人在线综合 | 99久久精品国产一区二区三区 | 久久免费精品国产 | 在线观看国产麻豆 | 久久综合久久伊人 | 91视频最新网址 | 日韩aⅴ视频 | 亚洲在线a | 日韩在线高清视频 | 91av亚洲| 超碰人人草 | 最新av观看 | 久久激情综合网 | 五月天丁香综合 | 亚洲精品www.| 久久久久久欧美二区电影网 | 久久久免费精品视频 | 婷婷色在线资源 | 正在播放国产一区 | 久久精品国产成人 | 久久久免费观看 | 狠狠躁日日躁夜夜躁av | 精品一区二区在线观看 | 亚洲 欧美 日韩 综合 | 婷婷资源站 | 欧美一区二区三区四区夜夜大片 | 中文字幕日本在线 | 欧美激情视频在线观看免费 | 97精品久久人人爽人人爽 | 天天色天天综合网 | 国产黄a三级三级三级三级三级 | 特级黄色一级 | 天天久久综合 | 国产成人精品999在线观看 | 三级黄色大片在线观看 | 在线观看视频 | 国产亚洲一级高清 | 久草视频一区 | 99精品免费久久久久久久久 | 在线国产一区 | 一区二区视频播放 | 免费男女羞羞的视频网站中文字幕 | 国产小视频91 | 欧美成人区 | 国产精品99久久免费黑人 | 亚洲精品动漫在线 | 国产精品美女999 | 国产精品18毛片一区二区 | 日韩精品大片 | 日韩高清成人在线 | 日韩精品久久中文字幕 | 国产综合精品一区二区三区 | 国产精品久久久久久久久久久久久久 | 国产高潮久久 | 顶级bbw搡bbbb搡bbbb | 亚洲电影院 | 美国三级黄色大片 | 五月婷婷精品 | 丝袜美腿在线 | 国产精品自产拍在线观看网站 | 久久,天天综合 | 久色小说| 国产伦精品一区二区三区四区视频 | 一区二区精品在线 | 欧美精品久久久久a | 久久久久99999 | 91国内在线 | 午夜国产在线 | 青草视频在线 | 99热这里只有精品国产首页 | 国内视频1区| 欧美视频18 | 99999精品视频| 免费在线观看视频a | 7777精品伊人久久久大香线蕉 | 国产日韩视频在线观看 | 亚洲国产成人高清精品 | 成人免费91| 久久久免费精品 | 最新国产福利 | 91在线区| 国产精品18久久久久vr手机版特色 | zzijzzij亚洲日本少妇熟睡 | 久久99精品国产91久久来源 | 在线视频app | 亚洲精品永久免费视频 | 亚洲精品在线观看中文字幕 | 人人爽夜夜爽 | 97色综合 | 亚洲精品小视频在线观看 | 国产手机精品视频 | av一区二区三区在线观看 | 91香蕉视频在线 | 日本中出在线观看 | 日韩欧美在线第一页 | 在线视频一二三 | 免费av高清 | 国产精品ssss在线亚洲 | 国产中文字幕av | 欧美国产不卡 | 91看片淫黄大片一级在线观看 | 国产尤物在线视频 | 91精品人成在线观看 | 夜夜视频资源 | 人人澡人人爽欧一区 | 欧美黄在线 | 在线有码中文 | 超碰日韩| 五月婷婷综合在线观看 | 成人av在线一区二区 | 天天色欧美 | 91精品免费视频 | 国产欧美久久久精品影院 | 欧美另类高清 | 久久dvd | www.夜色321.com | 黄免费在线观看 | 黄网站a | 亚洲精品乱码久久久久久蜜桃不爽 | 日本久草电影 | 国产美女精品视频 | 欧美,日韩 | 2019中文最近的2019中文在线 | 中文字幕国产一区二区 | 91精品久久久久久综合五月天 | zzijzzij亚洲成熟少妇 | 日韩一级电影在线 | 成人免费观看av | 国产精品久久久久久妇 | 国产一区欧美日韩 | 最近中文字幕在线 | 九九热国产视频 | 不卡国产视频 | 丁香婷婷久久久综合精品国产 | 涩涩成人在线 | 高清av免费一区中文字幕 | 日韩高清一区二区 | 丁香综合网| 久久人人爽人人爽 | 亚洲特级片 | 久久一区二区三区日韩 | 成年人在线电影 | 97av在线视频免费播放 | 五月天伊人 | 久久国产亚洲视频 | 国产一区二区在线免费 | japanesexxxhd奶水 91在线精品一区二区 | 亚洲视频 中文字幕 | 日韩有码在线观看视频 | 天天射天天舔天天干 | 在线看片91| 精品女同一区二区三区在线观看 | 欧美日韩在线免费观看视频 | 激情综合网五月婷婷 | 成人黄色在线看 | 不卡的av在线播放 | 亚洲欧美视频一区二区三区 | 欧美日韩在线观看视频 | 在线视频 国产 日韩 | 日韩精品在线看 | 免费a视频在线观看 | 欧美有色 | 国产精品久久久久久久久久久久久久 | 午夜视频久久久 | 玖玖视频在线 | 波多野结衣一区二区三区中文字幕 | 狠狠狠色丁香婷婷综合久久88 | 天天干天天看 | 韩日av在线 | 久久伦理 | 成人免费网站在线观看 | 手机色在线 | 欧美一级免费黄色片 | 国产一级视频 | 一区二区三区动漫 | 国产美女免费观看 | 天天操天天射天天添 | 国产不卡av在线播放 | 中文字幕在线视频精品 | 日韩免费视频网站 | 欧美电影在线观看 | 免费欧美精品 | 中文字幕成人一区 | 天天色天天色天天色 | 国产精品欧美 | 丁香在线视频 | 亚洲免费精彩视频 | 在线99热| 日本成人中文字幕在线观看 | 韩国一区二区三区视频 | 国产在线国偷精品产拍 | 国产精品亚洲a | 久久久精华网 | 激情久久五月天 | 亚洲精品午夜一区人人爽 | 日韩在线第一 | 精品国产成人av在线免 | 天天色.com| 天天天插 | 久久国产麻豆 | 天天射天天干天天插 | 久久专区 | 久久国产美女 | 国产亚洲久一区二区 | 日韩一级精品 | 在线三级播放 | 日韩网站在线看片你懂的 | 丝袜av一区 | 黄色国产精品 | 在线观看黄色的网站 | 91亚洲精品久久久久图片蜜桃 | 色狠狠狠| 国产三级久久久 | 日本69hd| 手机看片午夜 | 婷婷丁香久久五月婷婷 | 99热最新在线 | 国产精品久久亚洲 | 在线视频久| 91丨九色丨蝌蚪丰满 | 精品久久一区 | 久久综合网色—综合色88 | 国产精品电影一区 | 91亚洲夫妻 | 插插插色综合 | 久久免费的视频 | 国产一区二区三区免费在线 | 亚洲精品视频免费观看 | 亚洲精品乱码久久久一二三 | 久久极品 | 国产成人亚洲在线电影 | 一二三四精品 | 久草在线费播放视频 | 国产精品专区在线 | 99久久精品免费看国产 | 国产成人精品一区二区三区网站观看 | 丁香久久综合 | 日韩艹| 亚洲女欲精品久久久久久久18 | 天天艹日日干 | 天堂成人在线 | 99久久精品午夜一区二区小说 | 国产一区二区午夜 | 久 久久影院 | 国产综合在线视频 | 91成人精品观看 | 又色又爽的网站 | 伊人狠狠色丁香婷婷综合 | 亚洲精品mv在线观看 | 日韩欧美一区二区三区在线观看 | 婷婷色吧 | 天天人人 | 成人亚洲欧美 | 蜜臀一区二区三区精品免费视频 | av超碰在线 | 丁香婷婷综合网 | 97在线观看视频免费 | 国产精品成人免费一区久久羞羞 | 久久久久久免费毛片精品 | 少妇bbb好爽| 免费看片亚洲 | 在线观看国产亚洲 | 国产又粗又猛又黄又爽视频 | 国产91免费在线 | 九九热免费精品视频 | 免费a一级 | 精品视频久久久 | 在线观看视频黄 | 超碰人人舔 | 久久综合婷婷 | 成人av资源网站 | 激情欧美国产 | 亚洲三级性片 | 亚洲精品视频观看 | 国产欧美精品在线观看 | 欧美性春潮 | 在线一二三四区 | 一区二区精品在线观看 | 91av在线免费观看 | 超碰在线日韩 | 国产午夜精品久久久久久久久久 | 在线中文字幕观看 | 激情五月网站 | 蜜臀久久99精品久久久酒店新书 | 99精品视频免费观看视频 | 欧美va天堂在线电影 | 国产一区二区视频在线 | 国产免费不卡av | 中文字幕二区 | 久久dvd| 日韩欧美一区二区三区黑寡妇 | 黄av免费在线观看 | 日p在线观看 | 99视频国产精品免费观看 | 成人a免费 | 91麻豆精品国产91久久久更新时间 | 色综合久久久久久中文网 | 日韩av不卡在线观看 | 五月天精品视频 | 9999激情 | 国产精品99页| 免费三级a | 中文字幕免费观看 | 视频一区视频二区在线观看 | 中文字幕精 | 91久久久国产精品 | 久久久久久免费网 | 人人干人人艹 | 97人人模人人爽人人喊中文字 | 久久精品高清视频 | 欧美一二三区在线观看 | 欧美综合色在线图区 | 黄色在线观看免费网站 | 9在线观看免费高清完整 | 婷婷中文字幕综合 | 激情一区二区三区欧美 | 国产精品久久久久一区 | 97激情影院 | 国产黄av | 337p日本大胆噜噜噜噜 | 精品一二三区 | 三三级黄色片之日韩 | 蜜臀av免费一区二区三区 | 中文字幕一区二区三区四区久久 | 久久精品免费观看 | 国产精品18久久久久久久久久久久 | 国产成人精品av久久 | 中文字幕制服丝袜av久久 | 精品久久福利 | 国产a国产a国产a | 五月黄色 | 亚洲免费av在线 | 欧美在线free | 一级黄色大片在线观看 | 91最新地址永久入口 | 在线国产激情视频 | a在线一区| 国产破处视频在线播放 | 97av超碰| 美女网站免费福利视频 | a色网站| 黄色成人av网址 | 国产精品色视频 | 亚洲日b视频 | 久久都是精品 | 亚洲精品免费在线观看视频 | 99爱这里只有精品 | 在线导航av | 精品国产区 | 91在线免费播放视频 | 人人草在线观看 | 日三级在线 | 日韩在线观看小视频 | 日韩天堂在线观看 | 97免费在线视频 | 国产精品久久久久久久久久99 | 黄色亚洲在线 | 亚洲免费精品一区二区 | 成年人视频免费在线 | 亚洲手机天堂 | 久久99在线 | 欧美日韩3p | 91成年人在线观看 | 日韩在线免费高清视频 | 在线电影91| 国产在线精品国自产拍影院 | 91手机电视| 免费观看的av网站 | 91九色蝌蚪国产 | 99精品网站| a√天堂中文在线 | 色视频网址 | 天天操天天操天天操天天操天天操天天操 | 在线看岛国av | 成人av在线影院 | 五月天婷亚洲天综合网精品偷 | 超级碰碰碰视频 | 免费色黄 | 国产最新视频在线观看 | 日韩欧美高清一区二区三区 | 深爱激情婷婷网 | 久久精品网| 少妇性aaaaaaaaa视频 | 日韩欧在线 | 99热这里只有精品久久 | 国产剧情av在线播放 | 黄色毛片观看 | 亚洲精品自拍 | 亚洲精品黄色片 | 欧美日韩一级久久久久久免费看 | 天天操天天操天天爽 | 欧美一级性生活视频 | 91精品第一页 | 国产精品久久久久久久免费观看 | 国产这里只有精品 | 国产成人免费网站 | 999成人| 久久久视屏 | 深爱开心激情网 | 免费男女羞羞的视频网站中文字幕 | 九九九九精品九九九九 | 超碰成人免费电影 | 亚洲精品国产品国语在线 | 91 在线视频 | 97av影院 | 在线观看国产永久免费视频 | 午夜电影 电影 | 狂野欧美激情性xxxx欧美 | 国产一线在线 | 免费99精品国产自在在线 | 91免费网址| 久久国产精品免费 | 久久久国产精品亚洲一区 | 亚洲一级黄色 | 国内精品毛片 | 欧美精品久久久久性色 | 亚洲成人精品影院 | av在线等| 最新真实国产在线视频 | 国产小视频免费在线观看 | 黄色av一区二区 | 亚洲日本va午夜在线电影 | 亚洲国产99 | 日韩久久久久 | 亚洲黄色高清 | 国产不卡在线观看视频 | 久色小说 | 成年人在线观看 | 在线播放国产一区二区三区 | 91日韩在线播放 | 欧美日韩破处 | 国产日韩欧美综合在线 | 成人网在线免费视频 | 黄色特一级片 | 91热| 国产精品一区二区电影 | 奇米影视在线99精品 | 亚洲国产精品小视频 | 亚洲精品国产精品国自产在线 | 欧美亚洲成人免费 | 99精品福利视频 | 久久精品这里精品 | 91av资源在线 | 色综合久久久久综合体 | 国产精品视频不卡 | 免费网址在线播放 | 在线观看免费视频你懂的 | 韩国视频一区二区三区 | 国产精品女视频 | 国产视频一区精品 | 97超碰香蕉| 午夜丁香网 | 亚洲三级在线免费观看 | 欧美精品在线观看免费 | 五月激情六月丁香 | 国产精品久久久久永久免费看 | 女人18毛片90分钟 | 四虎影视成人永久免费观看视频 | 久色 网 | 日韩aⅴ视频 | 一区二区中文字幕在线播放 | 国产在线 一区二区三区 | 青春草免费视频 | 日韩高清在线看 | 在线看片一区 | 激情网五月 | 欧美激情另类文学 | 中文字幕第一页在线vr | 久久影视精品 | 国产最顶级的黄色片在线免费观看 | 久久久久久97三级 | 色综合国产 | 亚洲视频久久久久 | 成人在线黄色电影 | 九九免费在线视频 | 综合五月婷婷 | 99视频免费播放 | 欧美日韩在线观看一区二区三区 | 久久久久夜色 | 久久精品免费播放 | 色999视频 | 精品九九九 | 免费久久99精品国产婷婷六月 | 狠狠综合久久av | 色www精品视频在线观看 | 亚洲乱码久久 | 三日本三级少妇三级99 | 精品久久久久久久久久岛国gif | www色av| 狠狠色丁香婷婷综合 | 亚洲人成在| 在线观看中文 | 黄色av网站在线观看免费 | 久草在线在线视频 | 成人毛片a | 婷婷综合国产 | 激情婷婷在线 | 久久久久久久久毛片精品 | 欧美另类成人 | 超碰最新网址 | 日韩成人欧美 | 一级a毛片高清视频 | 国产精品高清免费在线观看 | 精品一区电影国产 | 精品福利网 | 91精品国产九九九久久久亚洲 | 中文字幕免费一区 | 亚洲黄色av一区 | www.成人久久 | 国产精品久久久久永久免费 | 超级碰碰碰碰 | 日韩精品一二三 | 高清久久久 | 婷婷伊人五月 | 黄色精品一区 | 午夜久久福利 | 国产亚洲小视频 | 婷婷性综合 | 国产精品成人久久久久 | 久久免费视频7 | 国产精品免费久久久久影院仙踪林 | 日韩,中文字幕 | 色婷婷免费视频 | 成年人免费观看国产 | 久久综合久色欧美综合狠狠 | 久久99九九99精品 | 最新av在线免费观看 | 久久久久久久久网站 | 国产免费观看久久黄 | 日韩av有码在线 | 99热99热 | 亚洲第一区在线播放 | 伊人手机在线 | 亚洲欧美日韩一区二区三区在线观看 | 国产专区视频在线观看 | 99视频免费看 | 五月天六月婷 | 久久美女精品 | 欧美国产日韩一区二区三区 | 日韩高清免费无专码区 | 欧美在线观看视频 | 免费在线激情电影 | 国产四虎影院 | 成人国产精品av | 精品久久久久久久久久久久久 | 久久黄页 | 欧美一级片在线免费观看 | 日韩视频一区二区在线观看 | 免费国产视频 | 欧美夫妻性生活电影 | 国产色婷婷精品综合在线手机播放 | 久久久久免费观看 | 最近中文字幕视频网 | 精品国产一区二区三区久久久久久 | 国产精品久久久久久久av大片 | 成人av在线资源 | 日日夜夜添 | 欧美美女视频在线观看 | 免费av网址大全 | 黄色av一区二区 | 四虎影视国产精品免费久久 | 日韩激情精品 | 久久久96| 五月天伊人| 国产手机av在线 | av免费看在线 | 91在线麻豆| 国产精品videoxxxx | 国产又粗又硬又爽的视频 | 午夜精品久久 | av免费看av| 最近中文字幕在线 | 国产精品男女 | 国产一区二区高清不卡 | 精品亚洲视频在线 | 亚洲午夜久久久久久久久久久 | 精品一区二区三区久久久 | 久草视频免费播放 | 一区视频在线 | av在线影片 | 国产精品麻豆欧美日韩ww | 亚洲精品婷婷 | 亚洲精品国产自产拍在线观看 | 91桃色在线观看视频 | 国内精品免费 | 黄色片视频免费 | 欧美一级免费在线 | 久久婷婷一区二区三区 | 国产精品久久在线观看 | 国产中的精品av小宝探花 | 久久久久久毛片 | 亚洲女人天堂成人av在线 | 精品福利视频在线观看 | 国产精品美女久久 | 中文字幕大全 | 日日操日日 | 久草在线免费电影 | 日本一区二区不卡高清 | 国产精品免费久久久久 | 亚洲国产免费 | 亚洲 综合 国产 精品 | 国产精品免费视频网站 | 国产精品mm | 精品一区二区电影 | 久久只精品99品免费久23小说 | 美女黄久久 | 国产精品一区免费在线观看 | 国产高清精品在线 | 狠狠ri | 亚洲精品美女在线 | 欧美激情视频在线观看免费 | 天天操夜夜看 | 国产成人三级一区二区在线观看一 | 高清国产午夜精品久久久久久 | 国产精品第一视频 | 久久国产精品99久久人人澡 | www.人人干| 四虎精品成人免费网站 | 偷拍精偷拍精品欧洲亚洲网站 | 丁香综合av | 国产综合精品一区二区三区 | 国产精品破处视频 | 最新国产精品亚洲 | 天堂久色 | 精品国产一二三四区 | 久久免费一 | 中文字幕一区二区三区精华液 | 超碰国产人人 | 视频一区二区在线观看 | 国产精品视频大全 | 亚洲天天在线 | 波多野结衣在线观看一区二区三区 | 欧美黑人xxxx猛性大交 | 国产精品麻豆欧美日韩ww | 中文字幕中文字幕在线一区 | 91精品1区2区 | 精品一二三区视频 | 日本特黄特色aaa大片免费 | 麻豆91精品91久久久 | 欧美动漫一区二区三区 | 九九热中文字幕 | 一区二区视频欧美 | 国产精品国产三级国产 | www免费网站在线观看 | 成人网看片 | 免费91麻豆精品国产自产在线观看 | 手机av电影在线观看 | 中文在线免费一区三区 | 手机在线观看国产精品 | 蜜臀av性久久久久av蜜臀妖精 | 夜夜视频欧洲 | 亚洲区另类春色综合小说 | 午夜国产在线 | 国产精品午夜久久 | 亚洲精品xxxx | 国产精品久久久久久电影 | 日本中文一区二区 | 色网影音先锋 | 97视频在线免费播放 | 久草| av中文字幕在线播放 | 久久视讯 | 婷婷中文字幕 | 视色网站 | 99看视频在线观看 | 久久久精品在线观看 | 久久久久一区二区三区四区 | 久久久精品久久 | 日韩高清一区二区 | 天天操比 | 婷婷午夜天 | 国产精选视频 | 免费观看国产视频 | 中文字幕资源站 | www..com黄色片| 天天干天天干天天干天天干天天干天天干 | 欧美日韩午夜 | 久久大视频 | 蜜臀aⅴ国产精品久久久国产 | 国产视频在线免费观看 | 中文字幕一区二 | 久久久久久欧美二区电影网 | 免费国产在线观看 | 特级毛片aaa | 日韩va在线观看 | 日韩欧美成人网 | 色婷婷在线视频 | 黄色三级免费网址 | www91在线观看 |